Python Forum
[PyGame] HELP ME DEBUG - Who wants to be a millionaire Game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] HELP ME DEBUG - Who wants to be a millionaire Game
#1
Below is my Code, i need help to make the Code move to a next question on click of the right BUTTON ANSWER and continuously.

from tkinter import*
import pygame

pygame.init()
root = Tk()
root.title("Kids game")
root.geometry('1352x652+0+0')
root.configure(background ='black')

#===============================---Frames------------------------------------------

ABC = Frame(root, bg='black')
ABC.grid()

ABC1= Frame(root, bg='black', bd=20, width=900, height=600)
ABC1.grid(row=0,column=0)
ABC2= Frame(root, bg='black', bd=20, width=452, height=600)
ABC2.grid(row=0,column=1)

ABC1a= Frame(ABC1, bg='black', bd=20, width=900, padx=150, height=200)
ABC1a.grid(row=0,column=0)
ABC1b= Frame(ABC1, bg='black', bd=20, width=900, height=200)
ABC1b.grid(row=1,column=0)
ABC1c= Frame(ABC1, bg='black', bd=20, width=900, height=200)
ABC1c.grid(row=2,column=0)

#===============================---Images--------------------------------------------------------

def Change50_50():
    canvas = Canvas(ABC1a, bg='black', width=180, height=80)
    canvas.grid(row=0, column=0)
    canvas.delete('all')
    image1 = PhotoImage(file = 'no50.png')
    canvas.create_image(90,40, image=image1)
    canvas.image = image1

def PeopleChange():
    canvas = Canvas(ABC1a, bg='black', width=180, height=80)
    canvas.grid(row=0, column=1)
    canvas.delete('all')
    image1 = PhotoImage(file = 'noPeople.png')
    canvas.create_image(90,40, image=image1)
    canvas.image = image1

def PhoneChange():
    canvas = Canvas(ABC1a, bg='black', width=180, height=80)
    canvas.grid(row=0, column=2)
    canvas.delete('all')
    image1 = PhotoImage(file = 'noPhone.png')
    canvas.create_image(90,40, image=image1)
    canvas.image = image1

def MillionPicture1():
    canvas = Canvas(ABC2, bg='black', width=350, height=600)
    canvas.grid(row=0, column=0)
    canvas.delete('all')
    image1 = PhotoImage(file = 'Picture1.png')
    canvas.create_image(215,300, image=image1)
    canvas.image = image1

def MillionPicture2():
    canvas = Canvas(ABC2, bg='black', width=350, height=600)
    canvas.grid(row=0, column=0)
    canvas.delete('all')
    image1 = PhotoImage(file = 'Picture2.png')
    canvas.create_image(215,300, image=image1)
    canvas.image = image1

def MillionPicture3():
    canvas = Canvas(ABC2, bg='black', width=350, height=600)
    canvas.grid(row=0, column=0)
    canvas.delete('all')
    image1 = PhotoImage(file = 'Picture3.png')
    canvas.create_image(215,300, image=image1)
    canvas.image = image1

def MillionPicture4():
    canvas = Canvas(ABC2, bg='black', width=350, height=600)
    canvas.grid(row=0, column=0)
    canvas.delete('all')
    image1 = PhotoImage(file = 'Picture4.png')
    canvas.create_image(215,300, image=image1)
    canvas.image = image1



#==================================Images---------------------------------------------------------

CentreImage = PhotoImage(file = 'millo.png')
LogoCentre  = Button(ABC1b, image = CentreImage, bg='black', width=300, height=200)
LogoCentre.grid()

Image50_50 = PhotoImage(file = 'pifty_pifty.png')
Live50_50  = Button(ABC1a, image = Image50_50, bg='black', width=180, height=80, command=Change50_50)
Live50_50.grid(row=0,column=0)

ImagePeople = PhotoImage(file = 'people_people.png')
LivePeople  = Button(ABC1a, image = ImagePeople, bg='black', width=180, height=80, command=PeopleChange)
LivePeople.grid(row=0,column=1)

ImagePhone = PhotoImage(file = 'phone_phone.png')
LivePhone  = Button(ABC1a, image = ImagePhone, bg='black', width=180, height=80, command=PhoneChange)
LivePhone.grid(row=0,column=2)

MillionImage = PhotoImage(file = 'Picture0.png')
MillionImg  = Button(ABC2, image = MillionImage, bg='black', width=350, height=600)
MillionImg.grid(row=0,column=0)

#===============================Million Questions ---------------------------------------

Question1 = StringVar()
Question2 = StringVar()
Question3 = StringVar()
Question4 = StringVar()
Question5 = StringVar()

Answer1 = StringVar()
Answer2 = StringVar()
Answer3 = StringVar()
Answer4 = StringVar()

Question1.set("Q1: What is 2 + 32")
Answer1.set("22")
Answer2.set("32")
Answer3.set("31")
Answer4.set("34")


def Question2():
    Question1.set("Q2: What is 5 + 5")
    Answer1.set("10")
    Answer2.set("55")
    Answer3.set("35")
    Answer4.set("2")
    MillionPicture1()
    def Quest(args):
        if args == 1:
            Question3()


def Question3():
    Question1.set("Q3: What is 7 * 7")
    Answer1.set("21")
    Answer2.set("14")
    Answer3.set("49")
    Answer4.set("7")
    MillionPicture2()

def Question4():
    Question1.set("Q4: What is 81 / 9")
    Answer1.set("19")
    Answer2.set("9")
    Answer3.set("49")
    Answer4.set("79")
    MillionPicture3()

def Question5():
    Question1.set("Q5: What is 9 * 2")
    Answer1.set("21")
    Answer2.set("18")
    Answer3.set("92")
    Answer4.set("29")
    MillionPicture4()

def Quest(args):
    if args == 1:
        Question2()
    if args == 2:
        Question3()

#===============================Text,Label,buttons---------------------------------------

txtQuestion = Entry(ABC1c, font=('arial', 18, 'bold'), bg='blue', fg='white', bd=5, width=44, justify=CENTER, textvariable =Question1)

txtQuestion.grid(row=0, column=0, columnspan=4, pady=4)

lblQuestionA = Label(ABC1c, font=('arial', 14, 'bold'),text='A: ', bg='black', fg='white', bd=5, justify=CENTER)
lblQuestionA.grid(row=1, column=0, pady=4, sticky=W)

txtQuestion1 = Button(ABC1c, font=('arial', 14, 'bold'), bg='blue', fg='white', bd=1, width=17, height=2, justify=CENTER, textvariable =Answer1)
txtQuestion1.grid(row=1, column=1, pady=4)


lblQuestB = Label(ABC1c, font=('arial', 14, 'bold'),text='B: ', bg='black', fg='white', bd=5, justify=LEFT)
lblQuestB.grid(row=1, column=2, pady=4, sticky=W)

txtQuestion2 = Button(ABC1c, font=('arial', 14, 'bold'), bg='blue', fg='white', bd=1, width=17, height=2, justify=CENTER, textvariable =Answer2)
txtQuestion2.grid(row=1, column=3, pady=4)


lblQuestC = Label(ABC1c, font=('arial', 14, 'bold'),text='C: ', bg='black', fg='white', bd=5, justify=LEFT)
lblQuestC.grid(row=2, column=0, pady=4, sticky=W)

txtQuestion3 = Button(ABC1c, font=('arial', 14, 'bold'), bg='blue', fg='white', bd=1, width=17, height=2, justify=CENTER, textvariable =Answer3)
txtQuestion3.grid(row=2, column=1, pady=4)


lblQuestD = Label(ABC1c, font=('arial', 14, 'bold'),text='D: ', bg='black', fg='white', bd=5, justify=LEFT)
lblQuestD.grid(row=2, column=2, pady=4, sticky=W)

txtQuestion4 = Button(ABC1c, font=('arial', 14, 'bold'), bg='blue', fg='white', bd=1, width=17, height=2, justify=CENTER, textvariable =Answer4, command =lambda:Quest(1))
txtQuestion4.grid(row=2, column=3, pady=4)
root.mainloop()
Reply
#2
Hi scidam it does show error, infact it runs but i was wondering how from Question 1 to produce a code that will check for the right answer in Question 2 and continuously, just like the WHO WANTS TO BE A MILLIONAIRE GAME
Reply
#3
(Jul-13-2019, 12:47 PM)gnasleeg Wrote: Hi scidam it does show error

Ok so share the error with us. We shouldn't have to run your code in order to figure out what's wrong with it. Especially since you're using images we don't have, so we couldn't even run it without changing your code.
Reply
#4
Either make a demo example of your problem or create a repo so we can run your code with your images.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020