-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathButton.py
More file actions
executable file
·29 lines (24 loc) · 1.15 KB
/
Copy pathButton.py
File metadata and controls
executable file
·29 lines (24 loc) · 1.15 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
#!/usr/bin/env python3
# -*-coding:utf-8 -*
import wx
class Frame1(wx.Frame):
def __init__(self):
super().__init__(None, wx.ID_ANY, 'Button example', wx.DefaultPosition, wx.Size(300, 300))
self.button1Clicked = 0
self.button2Clicked = 0
self.panel = wx.Panel(self)
self.button1 = wx.Button(self.panel, wx.ID_ANY, 'button1', wx.Point(50, 50))
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Click)
self.button2 = wx.Button(self.panel, wx.ID_ANY, 'button2', wx.Point(50, 100), wx.Size(200, 75))
self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Click)
self.staticText1 = wx.StaticText(self.panel, wx.ID_ANY, 'button1 clicked 0 times', wx.Point(50, 200))
self.staticText2 = wx.StaticText(self.panel, wx.ID_ANY, 'button2 clicked 0 times', wx.Point(50, 230))
def OnButton1Click(self, event):
self.button1Clicked += 1
self.staticText1.SetLabel('button1 clicked {0} times'.format(self.button1Clicked))
def OnButton2Click(self, event):
self.button2Clicked += 1
self.staticText2.SetLabel('button2 clicked {0} times'.format(self.button2Clicked))
application = wx.App()
Frame1().Show()
application.MainLoop()