Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Can';t为我的函数创建一个带有entry小部件和随机整数的if语句_Python 3.x_Function_If Statement_Tkinter_Tkinter Entry - Fatal编程技术网

Python 3.x Can';t为我的函数创建一个带有entry小部件和随机整数的if语句

Python 3.x Can';t为我的函数创建一个带有entry小部件和随机整数的if语句,python-3.x,function,if-statement,tkinter,tkinter-entry,Python 3.x,Function,If Statement,Tkinter,Tkinter Entry,我是tkinter和python的新手,在执行if语句时遇到了一个问题。我试图将条目与随机导入的整数进行比较,然后删除页面,并给出一个祝贺屏幕 我试图创建文本变量,但我不知道如何定义它,我被派去使用get命令,但我现在被困在这里 我非常感谢您的帮助,谢谢您抽出时间 from math import * from tkinter import * from tkinter import messagebox # Intro Window Creation window = Tk() window.

我是tkinter和python的新手,在执行if语句时遇到了一个问题。我试图将条目与随机导入的整数进行比较,然后删除页面,并给出一个祝贺屏幕

我试图创建文本变量,但我不知道如何定义它,我被派去使用get命令,但我现在被困在这里

我非常感谢您的帮助,谢谢您抽出时间

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()
我是tkinter和python的新手,在执行if语句时遇到了一个问题。我试图将条目与随机导入的整数进行比较,然后删除页面,并给出一个祝贺屏幕。我非常感谢您的帮助,谢谢您抽出时间

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()

.get()
的内容是字符串,因此不能将字符串与整数进行比较。可以将字符串转换为整数,也可以将字符串转换为整数。无需创建两个或三个
Tk
实例检查此链接非常感谢这对我非常有帮助再次感谢:D