I am confused about where to put the mainloop function in python. When I use this code:
from tkinter import *
import sys
window = Tk()
def mainFunct():
while True:
label = Label(window,text="Hello World")
label2 = Label(window, text = "Hello World2")
menu = input("Please input something")
if menu == "a":
label.pack()
if menu == "b":
label2.pack()
if menu == "c":
sys.exit()
window.mainloop()
mainFunct()
I want label to be packed when the user inputs a and when the user inputs b i want label2 to be packed. I am not sure when and why to use mainloop. Right now when I run the program, the GUi only pops up after I have inputted something and then I can't even input anything else and I think it has some thing to do with the window.mainloop() function because it just loops over and over again instead of running the while True loop again.