I want to create an app that starts on a main window and by pressing a button it should change to a diferent tkinter frame so the main frame should not be visible. The problem I have is that one frame overlaps another and I can see labels which shouldnt appear (labels of the main frame)
This is what I see on the main window: Main window
and this is what I see when I press the button: I just want to have the "Win 2" label
This is the code I have:
import tkinter
root = tkinter.Tk()
root.title("My Program")
root.geometry("700x350")
def swap_window():
win2 = tkinter.Frame(root).grid()
tag2 = tkinter.Label(win2, text="Win 2").grid(row=0, column=0)
main_window = tkinter.Frame(root).grid()
main_tag = tkinter.Label(main_window, text="Main window").grid(row=0, column=0)
btn_swap_window = tkinter.Button(main_window, text="Window 2", command=swap_window).grid(row=1, column=0)
root.grid()
root.mainloop()