mardi 25 février 2020

Can't create a if statement with a entry widget and a random integer for my function

I am new to tkinter and python, I ran into a problem during my if statements. I am trying to compare the entries to the randomly imported integers and delete the page and give a congrats screen.

I have tried to create text variable but I didn't know how to define it and I was sent to use get command but I'm stuck here now.

I would really appreciate any help and thank you for your time.

I am new to tkinter and python, I ran into a problem during my if statements. I am trying to compare the entries to the randomly imported integers and delete the page and give a congrats screen. I would really appreciate any help and thank you for your time.

from math import *
from tkinter import *
from tkinter import messagebox
# Intro Window Creation
window = Tk()
window.geometry("900x500")
window.title("Welcome To Practice Your Quadratic Equation Solving Skills")

# Picking Difficulty
def Introclick():
    window.destroy()
    windo = Tk()
    windo.geometry("900x500")
    windo.title("Difficulty Setting")
    label1 = Label(windo, text="Please enter your difficulty setting from ranging 1-3", bg="gray", font="Georgia 22")
    label1.pack()
    lebel2 = Label(windo, text="1 being the easiest and 3 being the hardest", bg="gray")
    lebel2.pack()

    def LV1():
        def destroy1():
            lOL.destroy()
        lOL=Tk()
        Answer11=Entry(lOL)
        Answer12=Entry(lOL)
        Answer11.pack()
        Answer12.pack()

        def crap():

            if y > x:
                if Answer11.get() == y and Answer12.get() == x:
                    lOL.destroy()
                    response = messagebox.askyesno("Great job you got it",  "Try again")
                else:
                    print("cry1")
            else:
                if Answer11.get() == x and Answer12.get() == y:
                    lOL.destroy()
                    response = messagebox.askyesno("Great job you got it", "Try again")
                else:
                    print("cry2")



        lOL.geometry("900x500")
        lOL.title("Level 1")
        z = Label(lOL, text="Easiest Difficulty")
        z.pack()
        lOL.configure(bg="gray")
        import random
        x = random.randint(1,5)
        y = random.randint(1,7)
        b = x + y
        c = x * y

        FunctionOut1=Label(lOL, text="Quadratic Equation \n" +"x^2  +  " + str(b) + "x  +  " + str(c), bg="gray", fg="green" )
        FunctionOut1.pack()
        Dead = Button(lOL, text="Exit", command=destroy1)
        Dead.pack()

        LAB11 = Label(lOL, text="Input both Answers, Integers Only")
        LAB11.pack()

        FAnswer1=Button(lOL, command=crap,text="Submit Answer")
        FAnswer1.pack()
# The buttons that allow to pick the difficulty
    B1 = Button(windo,text="Level 1", width=(20), command=LV1, fg="green", bg="gray")
    B2 = Button(windo,text="Level 2", width=(20), command=LV2, fg="yellow", bg="gray")
    B3 = Button(windo,text="Level 3", width=(20), command=LV3, fg="red", bg="gray")
    B1.pack()
    B2.pack()
    B3.pack()
    windo.configure(bg="gray")


Introbutt = Button(window, text="Let's Start!", padx=50, pady=50, command=Introclick, fg="blue", bg="black")
Introbutt.pack()


window.mainloop()

Aucun commentaire:

Enregistrer un commentaire