hi, im trying to learn tkinter and i want to create a number guessing game where you can choose difficulty but i have problems with checking the user input and printing if user has to guess higher, lower or if he is correct, cand you help me please?
here is the code:
here is the code:
from tkinter import * from tkinter import ttk import random root=Tk() root.geometry("500x175") root.title("Úroveň") #rooot2=Tk() ################################################################################ ################################################################################ def dva(): global ur_2 ur_2 = random.randint(1,100) #DONT CARE ABOUT THIS ONE def tri(): global ur_3 ur_3 = random.randint(1,500) #DONT CARE ABOUT THIS ONE def koniec(): #root2.destroy() Label(root2,text="Gratulujem, vyhral si!").pack(fill=BOTH) Button(root2,text="Znova?", command=root.iconify()).pack(fill=BOTH) Button(root2,text="Koniec", fg="red",command=root2.destroy()).pack(fill=BOTH) def start1(): global t2 root.destroy() root1=Tk() root1.geometry("250x175") root1.title("Hra") global ur_1 ur_1 = random.randint(1,10) l=Label(root1, text="Tipni si číslo", font=("Helvetica", 25)).pack() e1=Entry(root1, width=15).pack() b=Button(root1,text="OK", width=5, command=check1).pack() l1=Label(root1).pack(fill=BOTH) #DONT CARE ABOUT THIS ONE def start2(): global t2 root.destroy() root1=Tk() root1.geometry("250x175") root1.title("Hra") l=Label(root1, text="Tipni si číslo", font=("Helvetica", 25)).pack() e1=Entry(root1, width=15).pack() b=Button(root1,text="OK", width=5, command=check2).pack() l1=Label(root1, text="NIŽŠIE/VYŠŠIE").pack(fill=BOTH) #DONT CARE ABOUT THIS ONE def start3(): global t2 root.destroy() root1=Tk() root1.geometry("250x175") root1.title("Hra") l=Label(root1, text="Tipni si číslo", font=("Helvetica", 25)).pack() e1=Entry(root1, width=15).pack() b=Button(root1,text="OK", width=5, command=check3).pack() l1=Label(root1, text="NIŽŠIE/VYŠŠIE").pack(fill=BOTH) Label(root,text="Vyber si obtiažnosť", font=("Helvetica", 30)).pack(fill=BOTH) Button(root,text="Úroveň 1 (1-10)", fg="green", width=25, command=start1).pack(fill=BOTH) Button(root,text="Úroveň 2 (1-100)", fg="orange",width=25, command=start2).pack(fill=BOTH) Button(root,text="Úroveň 3 (1-500)", fg="red", width=25, command=start3).pack(fill=BOTH) root.mainloop() root1.mainloop() #root2.mainloop()