Karan Khanchandani
Karan Khanchandani

Reputation: 11

Python Tkinter : AttributeError: Button instance has no __call__ method

I don't know why this is giving me an attribute error. I want my blah() function to shuffle the cards. I'm calling the builtin function shuffle() from random.

Error:

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

Here's the code snippet:

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)

Upvotes: 0

Views: 2239

Answers (1)

TigerhawkT3
TigerhawkT3

Reputation: 49330

shuffle is the name of the function in random. However, it's also the name of the Button. Change the Button's name to something like shuffle_button and you should be fine.

Upvotes: 2

Related Questions