I'm just learning how to make a GUI with tkinter. There seems to be lots of resources on how to make new frames, but I cannot seem to find anything that explains how to actually add stuff within multiple frames without encountering problems.
I've got a Notebook as I'm using multiple tabs to view the 2 different frames I am using. Dead, simple, 2 buttons in the first frame, one hides the second tab and the other button shows the second tab. Within the second tab is the second frame. All works fine, but as soon as I put anything inside the second frame, both frames shrink down. Code is below:
from tkinter import *
from tkinter import ttk
root = Tk()
root.title('Tabs')
root.geometry("500x500")
my_notebook = ttk.Notebook(root)
my_notebook.pack(pady=15)
def hide():
my_notebook.hide(1)
def show():
my_notebook.add(my_frame2, text="Red Tab")
my_frame1= Frame(my_notebook, width=500, height=500, bg="blue")
my_frame2= Frame(my_notebook, width=500, height=500, bg="red")
my_frame1.pack(fill="both", expand=1)
my_frame2.pack(fill="both", expand=1)
my_notebook.add(my_frame1, text="Blue Tab")
my_notebook.add(my_frame2, text="Red Tab")
my_button = Button(my_frame1, text="Hide Tab2", command=hide).grid(row=0, column=0)
my_button2 = Button(my_frame1, text="Show Tab2", command=show).grid(row=1, column=1)
my_button3 = Button(my_frame2, text="Random button").grid(row=1, column=1)
root.mainloop()
When my_button3 is removed, everything looks fine. When it is in the code everything shrinks down. Does anyone know what I am doing that is causing this?