-
Notifications
You must be signed in to change notification settings - Fork 0
/
cps-test.py
93 lines (78 loc) · 2.82 KB
/
cps-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
import ttkbootstrap as ttk
from time import sleep
from threading import Thread
started = False
time = 1
_passed_time = 1
clicks = 0
def cps_test():
global clicks
if started:
clicks += 1
cps_label.set(str(clicks))
else:
output_string.set("")
passed_time.set(time)
cps_label.set("1")
Thread(target=cps_loop).start()
clicks += 1
def cps_loop():
global _passed_time, time, started
started = True
_passed_time = time
while _passed_time != 0:
sleep(1)
_passed_time += -1
passed_time.set(int(_passed_time))
started = False
cps = clicks / time
cps_label.set("Counting...")
output_string.set(f"cps : {cps}")
messagebox.showinfo(message=f"You got {cps} cps.", title="CPS Test ")
sleep(0.5)
reset()
def reset():
global clicks, started
cps_label.set("Click here!")
clicks = 0
started = False
def switch(value):
global time
passed_time.set(int(value))
time = value
# window
window = ttk.Window(themename = "vapor")
window.title("CPS Test")
window.geometry("500x350")
#Title
titel_string = ttk.StringVar()
titel_label = ttk.Label(master = window, text = "🔥 CPS Test 🔥", font = "Calibri 24 bold")
titel_label.pack()
#Set Time
input_frame = ttk.Frame(master = window)
time1 = ttk.Button(master = input_frame, text = "1", command=lambda: switch(1)).pack(side = "left",padx=10)
time2 = ttk.Button(master = input_frame, text = "2", command=lambda: switch(2)).pack(side = "left",padx=10)
time5 = ttk.Button(master = input_frame, text = "5", command=lambda: switch(5)).pack(side = "left",padx=10)
time10 = ttk.Button(master = input_frame, text = "10", command=lambda: switch(10)).pack(side = "left",padx=10)
time30 = ttk.Button(master = input_frame, text = "30", command=lambda: switch(30)).pack(side = "left",padx=10)
time60 = ttk.Button(master = input_frame, text = "60", command=lambda: switch(60)).pack(side = "left",padx=10)
time100 = ttk.Button(master = input_frame, text = "100", command=lambda: switch(100)).pack(side = "left",padx=10)
input_frame.pack(pady=10)
#Display time
passed_time = tk.StringVar()
passed_time.set(_passed_time)
time_label = tk.Label(master = window, text = "0", font = "Calibri 24 bold", textvariable=passed_time)
time_label.pack()
#click box
cps_label = tk.StringVar()
cps_label.set("Click here!")
cp = tk.Button(master=window, text="CPS", command=cps_test, font="Calibri 22", width=20, textvariable=cps_label)
cp.pack(pady=20)
#Output
output_string = tk.StringVar()
output_label = tk.Label(master = window, text = "output", font = "Calibri 22", textvariable=output_string)
output_label.pack(pady=5)
window.mainloop()