|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在按钮设置中,有一个问题感到不解
command=callback
为什么是:command=callback, 而不是 command=callback()
调用方法的话应该是调用callback()啊?
- from tkinter import *
- def callback():
- var.set('重新设置的文本')
- root = Tk()
- frame1 = Frame(root)
- frame2 = Frame(root)
- var = StringVar()
- var.set('这是一个会话框\n处于Frame1中...')
- textLabel = Label(frame1,
- textvariable=var,
- justify=LEFT)
- textLabel.pack(side=LEFT) # 在frame1中,文本标签置左
- photo = PhotoImage(file='Pic\LIVE_max.png')
- imgLabel = Label(frame1, image=photo)
- imgLabel.pack(side=RIGHT)
- theButton = Button(frame2,
- text='继续',
- command=callback) # 疑问:command=callback,而不是 command=callback()
- theButton.pack()
- frame1.pack(padx=10, pady=10)
- frame2.pack(padx=10, pady=10)
- mainloop()
复制代码 |
|