我不知道爲什麼這給我一個屬性錯誤。我希望我的blah()
功能可以洗牌。我正在從random
調用內置函數shuffle()
。Python Tkinter:AttributeError:按鈕實例沒有__call__方法
錯誤:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in __call__
return self.func(*args)
File "gui1.py", line 105, in blah
shuffle(cards)
AttributeError: Button instance has no __call__ method
下面的代碼片段:
def blah():
global card_count
global path
shuffle(cards)
card_count = 0
path = generate_paths(cards)
print "Cards Shuffled"
shuffle = Button(frame_buttons, text = "SHUFFLE",height = 2, width = 10,command =blah)
shuffle.grid(row = 2 , padx = 40, pady = 40)
您可以添加「Button」被定義和/或導入的代碼部分嗎? – 2015-04-05 07:52:32
'Button'是'tkinter'中的一個類。 – TigerhawkT3 2015-04-05 18:14:34