|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 WylLy 于 2016-4-27 23:04 编辑
代码如下:
- from tkinter import *
- def display(n):
- var.set(n)
-
- root = Tk()
- frame_button = Frame(root)
- frame_button.pack(fill = X)
- frame_button_one = Frame(frame_button)
- button_1 = Button(frame_button_one, text = '1', command = lambda: display(1))
- button_1.pack(side = LEFT)
- var = StringVar()
- var.set('abcd')
- display = Label(frame_display, textvariable = var)
- display.pack(side = RIGHT)
- mainloop()
复制代码
但是报错:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Program Files\Python\Python35\lib\tkinter\__init__.py", line 1549, in
__call__
return self.func(*args)
File "C:\Users\liyang\Desktop\calc.py", line 25, in <lambda>
button_1 = Button(frame_button_one, text = '1', command = lambda: display(1)
)
TypeError: 'Label' object is not callable
这个是怎么回事,求解答啊,这个button控件用的是否正确? |
|