-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClick_Counter.py
52 lines (35 loc) · 1 KB
/
Click_Counter.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
#This Tk for Click and Count use Tkinter
#This Program is Made to challenge myself, I call the program is One Day, One Program
#Program at June, 28, 2022
#Thank you
import tkinter as tk
count=0
def cal_add():
global count
count += 1
text.set("Your Counter : "+ str(count))
lhasil.config
def cal_minus():
global count
count -= 1
text.set("Your Counter : "+ str(count))
lhasil.config
def cal_double():
global count
count *= 2
text.set("Your Counter : "+ str(count))
lhasil.config
master = tk.Tk()
master.title("Click to Increase Count")
master.geometry("300x300")
btn=tk.Button(master, text="Click +1", command=cal_add)
btn.pack()
btn=tk.Button(master, text="Click -1", command=cal_minus)
btn.pack()
btn=tk.Button(master, text="Click x2", command=cal_double)
btn.pack()
text = tk.StringVar()
text.set("0")
lhasil=tk.Label(master,font=('Helvetica', 12, 'bold'),textvariable=text)
lhasil.pack()
master.mainloop()