Python Tkinter:AttributeError:Button实例没有__call__方法

时间:2015-04-05 05:44:51

标签: python button tkinter

我不知道为什么这会给我一个属性错误。我希望我的blah()功能可以随机播放卡片。我正在从shuffle()调用内置函数random

错误:

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)

1 个答案:

答案 0 :(得分:2)

shufflerandom中函数的名称。但是,它也是Button的名称。将Button的名称更改为shuffle_button,您应该没问题。