-
Notifications
You must be signed in to change notification settings - Fork 21
/
StyleApp.py
executable file
·73 lines (49 loc) · 1.8 KB
/
StyleApp.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
#!/usr/bin/env python
"""
This is a small wxPython app developed to demonstrate how to write in
Pythonic wxPython
"""
import wx
class DemoPanel(wx.Panel):
def __init__(self, parent, *args, **kwargs):
wx.Panel.__init__(self, parent, *args, **kwargs)
self.parent = parent
NothingBtn = wx.Button(self, label="Do Nothing with a long label")
NothingBtn.Bind(wx.EVT_BUTTON, self.DoNothing)
MsgBtn = wx.Button(self, label="Send Message")
MsgBtn.Bind(wx.EVT_BUTTON, self.OnMsgBtn )
Sizer = wx.BoxSizer(wx.VERTICAL)
Sizer.Add(NothingBtn, 0, wx.ALIGN_CENTER | wx.ALL, 5)
Sizer.Add(MsgBtn, 0, wx.ALIGN_CENTER | wx.ALL, 5)
self.SetSizerAndFit(Sizer)
def DoNothing(self, event=None):
pass
def OnMsgBtn(self, event=None):
dlg = wx.MessageDialog(self,
message='A completely useless message',
caption='A Message Box',
style=(wx.OK | wx.ICON_INFORMATION)
)
dlg.ShowModal()
dlg.Destroy()
class DemoFrame(wx.Frame):
""" This window displays a button """
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
# Build the menu bar
MenuBar = wx.MenuBar()
FileMenu = wx.Menu()
item = FileMenu.Append(wx.ID_EXIT, text="&Quit")
self.Bind(wx.EVT_MENU, self.OnQuit, item)
MenuBar.Append(FileMenu, "&File")
self.SetMenuBar(MenuBar)
# Add the Widget Panel
self.Panel = DemoPanel(self)
self.Fit()
def OnQuit(self, event=None):
self.Close()
if __name__ == "__main__":
app = wx.App(0)
frame = DemoFrame(None, title="Micro App")
frame.Show()
app.MainLoop()