tkinter-label

self.statusStr = tk.StringVar()
topFrame3 = tk.Frame()
self.status = tk.Label(topFrame3, textvariable=self.statusStr, fg="black", font=("simsun", 12),justify=tk.LEFT)
self.status.pack(side=tk.TOP)
self.statusStr.set('当前状态:准备...')
topFrame3.pack(side=tk.TOP)

# 动态修改颜色,字体
self.status.config(fg="red", font=("simsun", 16))
self.statusStr.set('当前状态:没有测量项可以计算,请先读取图形,载入测量项后计算...')

对齐方式

# 右对齐
a=Label(root,text='Hello World!', anchor="e")

text

tk.Label(topFrame, text="测量项公式:").pack(side=tk.LEFT)
self.measureParamEntry = tk.Text(topFrame, width=20, height=3)
self.measureParamEntry.pack(side=tk.LEFT, padx=4)
# 设置滚动条
scroll = tk.Scrollbar(topFrame)
scroll.pack(side=tk.RIGHT, fill=tk.Y)
# 将滚动条和文本框关联
scroll.config(command=self.measureParamEntry.yview)
self.measureParamEntry.config(yscrollcommand=scroll.set)

修改文字

# set the text
my_string_var.set("What should I learn")

# create a label widget
my_label = Label(Main_window,
textvariable = my_string_var)

添加信息

text.insert(END, text)

获取信息

To fetch the text contents of the widget, use the get method:

contents = text.get(1.0, END)

删除

self.measureParamText.delete('1.0', 'end')

禁止编辑

text.config(state=NORMAL)
text.insert(END,'我是插入内容')
text.config(state=DISABLED)