#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    19
    Rep Power
    0

    App not responding


    Hello,
    I was wondering why my program always crashes when I hit the button "play game". Is it the size of the program?

    Code:
    from Tkinter import *
    root = Tk()
    rank=0
    points=0
    root.geometry("900x1000+200+200")
    root.title("Math Game")
    var = StringVar()
    var2= StringVar()
    var3= StringVar()
    var4= StringVar()
    var5= StringVar()
    var6= StringVar()
    var7= StringVar()
    var8= StringVar()
    label1=Label(root, textvariable=var, relief=RAISED)
    var.set ("Welcome To the Math Game set 1")
    label1.pack()
    label2=Label(root, textvariable=var2, relief=RAISED)
    var2.set("Main Menu")
    label2.pack()
    def callback1():
        label3=Label(root, textvariable=var3, relief=RAISED)
        var3.set("About The Game:")
        label3.pack()
        label4=Label(root, textvariable=var4, relief=RAISED)
        var4.set("The Math Game is a good way to learn how to do math facts as well as doing the problems your self. There is also games with it!")
        label4.pack()
    
    def callback2():
        label5=Label(root, textvariable=var5, relief=RAISED)
        var5.set("Rank: " + str (rank))
        label5.pack()
    
    def callback3():
        label6=Label(root, textvariable=var6, relief=RAISED)
        var6.set("(10 rank = 1 point) Points are used to buy more levels and earn many differnt things. you have " + str (points) + " Points!")
        label6.pack()
    
    def callback4():
        label7=Label(root, textvariable=var7, relief=RAISED)
        var7.set("You are about to start the game!")
        label7.pack()
        Loading=0
        import random
        Questiona = random.randint(1, 10)
        Questionab = random.randint(1, 10)
        Questionaanswerreal = Questiona + Questionab
        label8 = Label(root, textvariable=var8, relief=RAISED)
        var8.set("Question 1: " + str (Questiona) + " + " + str (Questionab) + " = ?")
        label8.pack()
        Questionaansweruser = input()
        if Questionaansweruser == "str Questionaanswerreal":
            print ("print")
    
        
            
    b3=Button(root, text="Play Game", command=callback4)
    b3.pack()
    b2=Button(root, text="Points", command=callback3)
    b2.pack()     
    b1=Button(root, text="Rank", command=callback2)
    b1.pack()
    b=Button(root, text="About The Game", command=callback1)
    b.pack()
    
    def donothing():
       filewin = Toplevel(root)
       button = Button(filewin, text="Do nothing button")
       button.pack()
    
    
    menubar = Menu(root)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="New", command=donothing)
    filemenu.add_command(label="Open", command=donothing)
    filemenu.add_command(label="Save", command=donothing)
    filemenu.add_command(label="Save as...", command=donothing)
    filemenu.add_command(label="Close", command=donothing)
    
    filemenu.add_separator()
    
    filemenu.add_command(label="Exit", command=donothing)
    menubar.add_cascade(label="File", menu=filemenu)
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Undo", command=donothing)
    
    editmenu.add_separator()
    
    editmenu.add_command(label="Cut", command=donothing)
    editmenu.add_command(label="Copy", command=donothing)
    editmenu.add_command(label="Paste", command=donothing)
    editmenu.add_command(label="Delete", command=donothing)
    editmenu.add_command(label="Select All", command=donothing)
    
    menubar.add_cascade(label="Edit", menu=editmenu)
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Help Index", command=donothing)
    helpmenu.add_command(label="About...", command=donothing)
    menubar.add_cascade(label="Help", menu=helpmenu)
    root.mainloop()
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    Please spend some time learning about Entry widgets. And maybe the Text widget as well.

    After your code asks a question, enter the answer into the window from which you started the program.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo