Thanks so much for Helping, It's fixed now thanks to you guys.
The problem was after I got my cps count the program delayed and froze. It stopped showing the cps.
I can't find out why this happens or how to fix it. The program is a cps counter, it works after 1 try then it breaks and freezes if I use it a second time.
I also have no idea where the code breaks, thank you so much.
Here is the code:
import threading
from tkinter import *
import time
clicks = 0
cps = 0
start = True
wn = Tk()
wn.title("Cps Counter")
wn.geometry("400x300")
def cps5():
global start
global cps
global clicks
global t1
start = False
time.sleep(5)
cps = (clicks / 5)
clicks = 0
CpsButton.config(text=clicks)
CpsAmount.config(text=cps)
start = True
time.sleep(.1
t1 = threading.Thread(target=cps5)
t1.start()
def AddClicks():
global clicks
global start
clicks += 1
CpsButton.config(text=clicks)
if start == True:
cps5()
CpsButton = Button(wn, text=clicks, command=AddClicks, pady=15, padx=15)
CpsAmount = Label(wn, text=cps, pady=15, padx=15)
CpsAmount.pack()
CpsButton.pack()
wn.mainloop()
SyntaxErroraround thet1 =line due to an unclosed paren above it). And it's incredibly unsafe to do cross-threadtkintercalls like you're doing; use the event loop to schedule it with.after, don't launch a thread to callcps5. And don't usetime.sleep; the entire GUI will freeze while it's sleeping (again, that's what.afteris for); at a guess, you think it's broken because of thetime.sleep, not realizing that the GUI is just going to be non-responsive for a titch over five seconds whilecps5is running.