how to make input box if else statement in tkinter

Solutions on MaxInterview for how to make input box if else statement in tkinter by the best coders in the world

showing results for - "how to make input box if else statement in tkinter"
Chanelle
10 Jun 2020
1import tkinter
2
3root = tkinter.Tk()
4root.geometry("300x300")
5root.title("Try code")
6
7entry = tkinter.Entry(root)
8entry.pack()
9print(entry.get())
10def on_button():
11    if entry.get() == "Screen" or entry.get() == "screen": #corrected
12        slabel = tkinter.Label(root, text="Screen was entered")
13        slabel.pack()
14    else:
15        tlabel = tkinter.Label(root, text="")
16        tlabel.pack()
17
18button = tkinter.Button(root, text="Enter", command=on_button)
19button.pack()
20
21root.mainloop()
22