Vote count:
0
import time#allows the code to stop the code from running
score = 0
import tkinter
import threading
class MyTkApp(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def callback(self):
self.root.quit()
def run(self):
self.root=tkinter.Tk()
self.root.protocol("WM_DELETE_WINDOW", self.callback)
self.s = tkinter.StringVar()
self.s.set('your score is ' + str(score))
l = tkinter.Label(self.root,textvariable=self.s)
l.pack()
self.root.mainloop()
app = MyTkApp()
time.sleep(1)
root = tkinter.Tk
input("\nPress enter to start. ")
print(" _____ ")
print(" / | | ")
print(" / | |_")
print("/ ^ /")
print("\____ | ")
print(" |__| ")
time.sleep(1)#allows the code to stop the code from running
print(" ________ _________ ")
print(" \_____ \ \______ /")
print(" _(__ < / /")
print(" / \ / / ")
print(" /______ / /____/ ")
print(" \/")
time.sleep(1)
print(" ____ .________")
print(" /_ | | ____/")
print(" | | |____ \ ")
print(" | | / |")
print(" |___| /______ /")
print(" \/ ")
time.sleep(1)
print("Hello what is you name")
name = input()#the user inputs their name
print("Welcome " + name + " to")#prints their name as well as some other things
time.sleep
time.sleep(2)
print("what is 2 + 2")
hello = input()#this allows the user to input their answer
if hello == "4":#if there answer is 4 then it will:
score = score + 1#add the 1 to their score
print("well done")
else:#if their answer is wrong it will ask this question:
print("would you like to retry type y/n")
y_n = input()#the user inputs y/n
if y_n == "y":#if it is y it will carry on and ask:
print("what it 2 + 2")
answer = input()
if answer == "4":#if there answer is 4 then it will:
print("well done your score is")
score = score + 0.5
else:#if it is wrong their cant try again
print("sorry no more trys")
print("Your score is still the same")
else:
print("ok")
print("Your score is still the same")
#the same is done for the rest of the code but the end
I am sorry that this is the same question but i have added more info and the other question was not going off hold!
this is an UP TO DATE code that i cannot refresh please help????????? this is a maths game that is only the beginning but it is just enough to look at what i am looking and asking for. please tell me how to do it in code. and explain how to and why it works. what i am trying to do is have it so your score is always in the GUI and when you get a question right your score changes by 1 and the score on the GUI changes as well. I have tried to do root.update() and doesnt work also i have tried to close the GUI but it doesnt work it comes up with an error. i think that i would need it to be in the first if but i am not sure.
asked 40 secs ago
I'm making a maths games where the score is shown in a GUI but it will not update when you get a score?
Aucun commentaire:
Enregistrer un commentaire