First off, I'm new to coding. And I'm following a course on it. But in the meantime I want to test myself and figure things out for myself and "learn on the job" a bit with more hands on coding that I can use right away.
I've written below code to try and figure out to make a main window with 2 buttons. If I press a button, it should change the screen into the second/third screen. But instead if I fire up my exe. It opens all 3 windows right away in separate windows. And once I press a button it opens another window. But what I would want is that the main window get's "updated" to show only the labels/pictures/buttons etc (which I did not include in the .py yet).
from tkinter import *
def second_window1():
second_window1 = Toplevel(main)
second_window1.title("Second window")
second_window1.geometry("414x896")
Label(second_window1, text ="This is the second window")#.pack()
def third_window1():
third_window1 = Toplevel(main)
third_window1.title("Third window")
third_window1.geometry("414x896")
Label(third_window1, text ="This is the third window")#.pack()
main = Tk()
main.title("Main Screen")
main.geometry('414x896')
main.configure(background = "azure2")
main.resizable(False, False)
Label(main, text = "Label_1", fg = "chartreuse2", bg = "ghostwhite", font = "Helvetica 16 bold").grid(row=1, column=1)
second_window = Tk()
second_window.title("Second Screen")
second_window.geometry('414x896')
second_window.configure(background = "azure2")
second_window.resizable(False, False)
Label(main, text = "Label_2", fg = "chartreuse2", bg = "ghostwhite", font = "Helvetica 16 bold").grid(row=1, column=1)
third_window = Tk()
third_window.title("Third Screen")
third_window.geometry('414x896')
third_window.configure(background = "azure2")
third_window.resizable(False, False)
Label(main, text = "Label_3", fg = "chartreuse2", bg = "ghostwhite", font = "Helvetica 16 bold").grid(row=1, column=1)
btn = Button(main, text ="Second Screen", command = second_window1).grid(row=1, column=1)
btn = Button(main, text ="Third Screen", command = third_window1).grid(row=2, column=1)
mainloop()