rybro1 0 Newbie Poster

im making a maths game but i need to know how to make 10 random questions appear in a text box for easy medium and hard addition and subtraction with 1-100 for easy, 1-200 for medium and 1-500 for hard..please help me =)

from Tkinter import *
import Tkinter as tk
import random
 
root = tk.Tk()
root.title('Maths Game')
root.geometry("500x500")

def main_menu():
    image2 = tk.PhotoImage(file="menu.gif")
    w = image2.width()
    h = image2.height()
    root.geometry("%dx%d+0+0" % (w, h))

    global panel2   
    panel2 = tk.Label(root, image=image2)
    panel2.pack(side='top', fill='both', expand='yes')

    add_button = tk.Button(panel2, text= "Addition", command = addition)
    add_button.place_configure(w = 130, h =130 , x=90 , y =200 )

    sub_button = tk.Button(panel2, text= "Subtraction", command = subtraction)
    sub_button.place_configure(w = 130, h =130 , x=300 , y =200 )

    help_button = tk.Button(panel2, text= "Help", command = Help)
    help_button.place_configure(w = 130, h =45 , x=50 , y =400 )

    info_button = tk.Button(panel2, text= "About the author", command = about)
    info_button.place_configure(w = 130, h =45 , x=190 , y =400 )

    quit_button = tk.Button(panel2, text= "Quit", command = Quit)
    quit_button.place_configure(w = 130, h =45 , x=330 , y =400 )

    panel2.image= image2
    
def addition():
    panel2.destroy()
    
    image3 = tk.PhotoImage(file="difficulty.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel3
    
    panel3 = tk.Label(root, image=image3)
    panel3.pack(side='top', fill='both', expand='yes')
    panel3.image = image3

    menu_button = tk.Button(panel3, text= "Menu", command = main3)
    menu_button.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button1 = tk.Button(panel3, text= "Quit", command = Quit)
    quit_button1.place_configure(w = 40, h =35, x=457 , y =460)
    
    easy_button = tk.Button(panel3, text= "Easy", command = add_easy)
    easy_button.place_configure(w = 120, h =100, x=190, y=150)
    
    medium_button = tk.Button(panel3, text= "Medium", command = add_medium)
    medium_button.place_configure(w = 120, h =100, x=190, y=260)
    
    hard_button = tk.Button(panel3, text= "Hard", command = add_hard)
    hard_button.place_configure(w = 120, h =100, x=190, y=370)
    
def subtraction():
    panel2.destroy()
    
    image3 = tk.PhotoImage(file="difficulty.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel3
    
    panel3 = tk.Label(root, image=image3)
    panel3.pack(side='top', fill='both', expand='yes')
    panel3.image = image3

    menu_button1 = tk.Button(panel3, text= "Menu", command = main3)
    menu_button1.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button2 = tk.Button(panel3, text= "Quit", command = Quit)
    quit_button2.place_configure(w = 40, h =35, x=457 , y =460)
    
    easy_button1 = tk.Button(panel3, text= "Easy", command = sub_easy)
    easy_button1.place_configure(w = 120, h =100, x=190, y=150)
    
    medium_button1 = tk.Button(panel3, text= "Medium", command = sub_medium)
    medium_button1.place_configure(w = 120, h =100, x=190, y=260)
    
    hard_button1= tk.Button(panel3, text= "Hard", command = sub_hard)
    hard_button1.place_configure(w = 120, h =100, x=190, y=370)
    
def add_easy():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="easy.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel4
    
    panel4 = tk.Label(root, image=image3)
    panel4.pack(side='top', fill='both', expand='yes')
    panel4.image = image3

    menu_button2 = tk.Button(panel4, text= "Menu", command = main2)
    menu_button2.place_configure(w = 40, h =35, x=0 , y =460)

    label1 = Label(root, text='Question:')
    label1.place_configure(w = 60, h =20, x=150 , y =150)

    question = Text(root)
    question.place_configure(w = 60, h =20, x=150 , y =170)

    answer = Entry(root)
    answer.place_configure(w = 100, h =50, x=150 , y =220)
        
            
    submit = tk.Button(panel4, text= "Submit")
    submit.place_configure(w = 100, h =80, x=200 , y =350)

    quit_button3 = tk.Button(panel4, text= "Quit", command = Quit)
    quit_button3.place_configure(w = 40, h =35, x=457 , y =460)
   
def add_medium():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="medium.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel4
    
    panel4 = tk.Label(root, image=image3)
    panel4.pack(side='top', fill='both', expand='yes')
    panel4.image = image3

    menu_button3 = tk.Button(panel4, text= "Menu", command = main2)
    menu_button3.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button4 = tk.Button(panel4, text= "Quit", command = Quit)
    quit_button4.place_configure(w = 40, h =35, x=457 , y =460)

def add_hard():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="medium.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel4
    
    panel4 = tk.Label(root, image=image3)
    panel4.pack(side='top', fill='both', expand='yes')
    panel4.image = image3

    menu_button4 = tk.Button(panel4, text= "Menu", command = main2)
    menu_button4.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button5 = tk.Button(panel4, text= "Quit", command = Quit)
    quit_button5.place_configure(w = 40, h =35, x=457 , y =460)

def sub_easy():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="easy.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel7
    
    panel7 = tk.Label(root, image=image3)
    panel7.pack(side='top', fill='both', expand='yes')
    panel7.image = image3

    menu_button2 = tk.Button(panel7, text= "Menu", command = main5)
    menu_button2.place_configure(w = 40, h =35, x=0 , y =460)

    label1 = Label(root, text='Question:')
    label1.place_configure(w = 60, h =20, x=150 , y =150)    

    quit_button3 = tk.Button(panel7, text= "Quit", command = Quit)
    quit_button3.place_configure(w = 40, h =35, x=457 , y =460)

def sub_medium():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="medium.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel7
    
    panel7 = tk.Label(root, image=image3)
    panel7.pack(side='top', fill='both', expand='yes')
    panel7.image = image3

    menu_button3 = tk.Button(panel7, text= "Menu", command = main5)
    menu_button3.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button4 = tk.Button(panel7, text= "Quit", command = Quit)
    quit_button4.place_configure(w = 40, h =35, x=457 , y =460)


def sub_hard():
    panel3.destroy()
    
    image3 = tk.PhotoImage(file="medium.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))

    global panel7
    
    panel7 = tk.Label(root, image=image3)
    panel7.pack(side='top', fill='both', expand='yes')
    panel7.image = image3

    menu_button4 = tk.Button(panel7, text= "Menu", command = main5)
    menu_button4.place_configure(w = 40, h =35, x=0 , y =460)

    quit_button5 = tk.Button(panel7, text= "Quit", command = Quit)
    quit_button5.place_configure(w = 40, h =35, x=457 , y =460)
    
    quit_button5 = tk.Button(panel7, text= "Quit", command = Quit)
    quit_button5.place_configure(w = 40, h =35, x=457 , y =460)

    
    
def Help():
    panel2.destroy()
    
    image3 = tk.PhotoImage(file="help.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))
    
    global panel5
    
    panel5 = tk.Label(root, image=image3)
    panel5.pack(side='top', fill='both', expand='yes')
    panel5.image = image3
    
    menu_button5 = tk.Button(panel5, text= "Main Menu", command = main4)
    menu_button5.place_configure(w = 130, h =45, x=90 , y =400)
    
    quit_button6 = tk.Button(panel5, text= "Quit", command = Quit)
    quit_button6.place_configure(w = 130, h =45, x=300 , y =400)

def main5():
    panel7.destroy()
    main_menu()
def main4():
    panel5.destroy()
    main_menu()

def main3():
    panel3.destroy()
    main_menu()
    
def main2():
    panel4.destroy()
    main_menu()
    
def about():
    panel2.destroy()
    
    image3 = tk.PhotoImage(file="author.gif")
    w = image3.width()
    h = image3.height()
    
    root.geometry("%dx%d+0+0" % (w, h))
    
    global panel6
    
    panel6 = tk.Label(root, image=image3)
    panel6.pack(side='top', fill='both', expand='yes')
    panel6.image = image3
    
    menu_button6 = tk.Button(panel6, text= "Main Menu", command = main1)
    menu_button6.place_configure(w = 130, h =45, x=90 , y =400)
    
    quit_button7 = tk.Button(panel6, text= "Quit", command = Quit)
    quit_button7.place_configure(w = 130, h =45, x=300 , y =400)

def main1():
    panel6.destroy()
    main_menu()

def main():
    panel1.destroy()
    main_menu()
    
def Quit():
    root.destroy()

image1 = tk.PhotoImage(file="splash.gif")
w = image1.width()
h = image1.height()

root.geometry("%dx%d+0+0" % (w, h))

panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')

begin_button = tk.Button(panel1,text = "Begin",command = main)
begin_button.place_configure(w = 150, h = 55, x= 190, y = 400)

panel1.image = image1

root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.