Nov-20-2019, 09:16 PM
when you define your button, include a 'command' attribute which will contain the address of function you wish to execute when button is pressed (when I say address, I am refering to the function name minus the () which would cause it to execute.
Example:
Example:
import tkinter as tk def clicked(): print("you pressed the button") # add logic here: # has new set of buttins been declared? # if not, define new set def main(): root = tk.Tk() # give it sone size root.geometry('100x100+10+10') frame = tk.Frame(root) frame.pack(fill=tk.BOTH) button = tk.Button(frame, text='Click Me', command=clicked) button.pack() root.mainloop() if __name__ == '__main__': main()