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)
|
修改文字
my_string_var.set("What should I learn")
my_label = Label(Main_window, textvariable = my_string_var)
|
添加信息
获取信息
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)
|