Reputation: 832
I am trying to make a GUI in Tkinter, want the GUI to have 2 tabs. I am using ttk.notebook
for that.
My code is as follows:
root=tk.Tk()
root.title("Data Tool")
root.geometry("500x300")
nb = ttk.Notebook(root)
nb.place(relx=0,rely=0)
# Adds tab 1 of the notebook
page1 = ttk.Frame(nb)
nb.add(page1, text='Home')
# Adds tab 2 of the notebook
page2 = ttk.Frame(nb)
nb.add(page2, text='Tool')
tk.Label(page1,text="test",bg="red").place(relx=0.2,rely=0.4)
root.mainloop()
This GUI is not showing the label on page1. What could be wrong in the code?
Upvotes: 0
Views: 245
Reputation: 22493
Your label's master is set to page1
which is an empty frame, and then you call place
on the label using relx
and rely
. To show the widget, your frame need to have a size:
page1 = ttk.Frame(nb,height=400,width=400)
Upvotes: 2