May-02-2022, 02:45 PM
I am trying to put buttons on my tabs. The buttons appear, but when I click them, nothing happens.
It looks like the code for the buttons gets run when I run the program, but not when I click on the buttons.
Any help would be appreciated.
Here is the code
It looks like the code for the buttons gets run when I run the program, but not when I click on the buttons.
Any help would be appreciated.
Here is the code
from tkinter import * from tkinter import ttk def create_child(tid): print("creating child",tid) root = Tk() root.title("Tab Widget") tabControl = ttk.Notebook(root) tab1 = ttk.Frame(tabControl) tab2 = ttk.Frame(tabControl) tabControl.add(tab1, text ='Tab 1') tabControl.add(tab2, text ='Tab 2') tabControl.pack(expand = 1, fill ="both") ttk.Label(tab1,text ="Test Tab 1").pack(side="top") ttk.Label(tab2,text ="Test Tab 2").pack(side="top") btn1 = Button(tab1,text='Create Record',font=("Times",16),command=create_child("Button 1 clicked")) btn2 = Button(tab2,text='Create Record',font=("Times",16),command=create_child("Button 2 clicked")) btn1.pack(side="bottom") btn2.pack(side="bottom") root.mainloop()