How to make a timerTraceback (the initial time is 5 secondsmost recent call last):
File "C:\Users\User\Desktop\game 1.9.1.py", when it reaches zeroline 76, the score is resetin
but_1 = Button(text='1', except for the recordwidth=3, and when you press the right buttonheight=1, the time is restoredbg='blue', font='Hack 30', command=click_button, true = 1)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", random numbersline 2679, in init
Widget.init(when you press the right buttonself, the time is restored and adds 1 point to the scoremaster, as well as'button', cnf, kw)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 2601, in init
self.tk.call(
_tkinter.TclError: unknown option "-true"
I planned to the record ifmake 1 correct button, and that it is beatenwould change. And if the score is reset incorrectly) record forWhen you click on the game (whencorrect button, the score is greater than the recordadded to 1, it (record) overwritten and saved after exiting the game) a link to the site (there will be an icon in the corner if you click on it is incorrect, the site will open) and how to make this game available for Android(.apk) in python? Thescore is reset
The game code itself:
from tkinter import *
import random as rn
import time
rn.seed()
timer = TIME = 5
root = Tk()
root.title('game')
root.geometry('720x1280')
true = 0
clicks = 0
def click_button():
global clicks, timer, true
clicks += 1
timer = TIME
labelClick['text'] = str(clicks)
labelClick.pack() #Variable clicks
count = rn.randrange(1,10,1)
print(count)
count = str(count) #randomizer of the correct button
if count == '1':
bgcolor='blue'
if count == '2':
bgcolor='green'
if count == '3':
bgcolor='red'
if count == '4':
bgcolor='yellow'
if count == '5':
bgcolor='orange'
if count == '6':
bgcolor='brown'
if count == '7':
bgcolor='violet'
if count == '8':
bgcolor='grey'
if count == '9':
bgcolor='pink'
#bgcolor='blue' #random numbers and colors
but_0 = Button(text=count, width=3, height=1, bg= bgcolor, font='Hack 30', command=click_button)
print(bgcolor)
but_0.place(x=310, y=140)
but_0['state'] = 'disabled'
counter = 1000
def countdown():
global timer, counter
global clicks
print(timer)
timer -= 1
counter -= 5
if timer <= 0:
clicks -= clicks
timer = 5
root.after(counter, countdown)
but_10 = Button(text=timer, width=3, height=1, font='Hack 30', command=click_button)
print(timer)
but_10.place(x=310, y=40)
but_10['state'] = 'disabled' #A button with the right button
labelClick = Label(root, text=clicks)
labelClick.pack()
but_1 = Button(text='1', width=3, height=1, bg='blue', font='Hack 30', command=click_button, true = 1)
but_2 = Button(text='2', width=3, height=1, bg='green', font='Hack 30', command=click_button, true = 2)
but_3 = Button(text='3', width=3, height=1, bg='red', font='Hack 30', command=click_button, true = 3)
but_4 = Button(text='4', width=3, height=1, bg='yellow', font='Hack 30', command=click_button, true = 4)
but_5 = Button(text='5', width=3, height=1, bg='orange', font='Hack 30', command=click_button, true = 5)
but_6 = Button(text='6', width=3, height=1, bg='brown', font='Hack 30', command=click_button, true = 6)
but_7 = Button(text='7', width=3, height=1, bg='violet', font='Hack 30', command=click_button, true = 7)
but_8 = Button(text='8', width=3, height=1, bg='grey', font='Hack 30', command=click_button, true = 8)
but_9 = Button(text='9', width=3, height=1, bg='pink', font='Hack 30', command=click_button, true = 9) #Buttons
if true == count:
clicks += 1
else:
clicks = 0
but_1.place(x=210, y=240)
but_2.place(x=310, y=240)
but_3.place(x=410, y=240)
but_4.place(x=210, y=340)
but_5.place(x=310, y=340)
but_6.place(x=410, y=340)
but_7.place(x=210, y=440)
but_8.place(x=310, y=440)
but_9.place(x=410, y=440) #button layout
root.after(1, countdown)
root.mainloop()