-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathButton.py
More file actions
executable file
·48 lines (35 loc) · 1.47 KB
/
Copy pathButton.py
File metadata and controls
executable file
·48 lines (35 loc) · 1.47 KB
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
#!/usr/bin/env python3
# -*-coding:utf-8 -*
import tkinter
import tkinter.ttk
class Form1(tkinter.Tk):
def __init__(self):
super().__init__()
self.button1Clicked = 0
self.button2Clicked = 0
self.panel = tkinter.ttk.Frame(self)
self.panel.pack(fill = tkinter.BOTH, expand=1)
self.button1 = tkinter.ttk.Button(self.panel, command=self.OnButton1Click, text="button1")
self.button1.place(x=50, y=50)
self.frameButton = tkinter.ttk.Frame(self.panel, width=200, height=75)
self.frameButton.pack_propagate(0)
self.frameButton.place(x = 50, y = 100)
self.button2 = tkinter.ttk.Button(self.frameButton, command=self.OnButton2Click, text="button2")
self.button2.pack(fill = tkinter.BOTH, expand=1)
self.label1 = tkinter.ttk.Label(self.panel, text="button1 clicked {0} times".format(self.button1Clicked))
self.label1.place(x=50, y=200)
self.label2 = tkinter.ttk.Label(self.panel, text="button2 clicked {0} times".format(self.button2Clicked))
self.label2.place(x=50, y=230)
self.geometry("300x300+200+100")
self.title("")
def main(self=None):
form = Form1()
form.mainloop()
def OnButton1Click(self):
self.button1Clicked += 1
self.label1["text"] = "button1 clicked {0} times".format(self.button1Clicked)
def OnButton2Click(self):
self.button2Clicked += 1
self.label2["text"] = "button2 clicked {0} times".format(self.button2Clicked)
if __name__ == '__main__':
Form1.main()