Tkinter - ask a widget for its callback Tkinter - ask a widget for its callback tkinter tkinter

Tkinter - ask a widget for its callback


It would be a much better idea to put a print command in the function and then press the button to see what happens. If you don't want the code to execute, you can just comment out all the other code.

def func1():    doStuff()    print ("Function 1 has been called")def func2():    #doStuff2()    print ("Function 2 has been called")def func3():    print ("Function 3 has been called")button = Button(root, text="Call funaction 2", command=func2) #Etc....

EDIT:I'm not sure if this is a good idea, but you can try using the _tclCommands variable in the button which will return a list. What's in the list? I'll be honest, I'm not entirely sure, but check this out from me trying it out:

>>> from tkinter import *>>> root = Tk()>>> def epic():...     print ("EPIC")...>>> b = Button(root, command=epic)>>> b.grid()>>> b._tclCommands['28020208epic']>>> epic<function epic at 0x013D1468>>>>