-
Notifications
You must be signed in to change notification settings - Fork 21
/
SimpleSizer3.py
executable file
·72 lines (57 loc) · 2.5 KB
/
SimpleSizer3.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
#!/usr/bin/env python
import wx
class TestFrame(wx.Frame):
def __init__(self, parent, ID, title=""):
wx.Frame.__init__(self, parent, -1, title, style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
ID_CODE = wx.NewId()
# Set Controls
label_name = wx.StaticText(self, -1, "Name: ")
self.name = wx.TextCtrl(self, -1, "A name", wx.DefaultPosition, (200, 20))
label_sysfile = wx.StaticText(self, -1, "System file: ")
self.sysfile = wx.TextCtrl(self, -1, " A file", wx.DefaultPosition, (200, 20))
button_sysfile = wx.Button(self, ID_CODE, "View Code")
label_sysname = wx.StaticText(self, -1, "System name: ")
self.sysname = wx.TextCtrl(self, -1, " A sysname", wx.DefaultPosition, (200, 20))
line = wx.StaticLine(self, -1)
buttonOK = wx.Button(self, wx.ID_OK, "OK")
buttonOK.SetDefault()
buttonCancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
# Do Layout
sizer = wx.BoxSizer(wx.VERTICAL)
box1 = wx.BoxSizer(wx.HORIZONTAL)
box1.Add(label_name, 0, wx.LEFT, 5)
box1.Add((1, 1), 1)
box1.Add(self.name, 0, wx.ALIGN_RIGHT, 5)
sizer.Add(box1, 0, wx.EXPAND | wx.ALL, 5)
box5 = wx.BoxSizer(wx.HORIZONTAL)
box5.Add(label_sysfile, 0, wx.LEFT, 5)
box5.Add((1, 1), 1)
box5.Add(self.sysfile, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER, 5)
sizer.Add(box5, 0, wx.EXPAND | wx.ALL, 5)
sizer.Add(button_sysfile, 0, wx.ALIGN_TOP | wx.ALIGN_RIGHT, 5)
sizer.Add((1,10), 0, wx.EXPAND)
box6 = wx.BoxSizer(wx.HORIZONTAL)
box6.Add(label_sysname, 0, wx.LEFT, 5)
box6.Add((1, 1), 1, wx.GROW)
box6.Add(self.sysname, 0, wx.ALIGN_RIGHT, 5)
sizer.Add(box6, 0, wx.EXPAND | wx.ALL, 5)
sizer.Add(line, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
sizer.Add((1, 1), 1, wx.EXPAND)
box7 = wx.BoxSizer(wx.HORIZONTAL)
box7.Add(buttonOK, 0, wx.ALIGN_CENTER | wx.ALL, 5)
box7.Add(buttonCancel, 0, wx.ALIGN_CENTER | wx.ALL, 5)
sizer.Add(box7, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5)
self.SetSizer(sizer)
self.SetAutoLayout(True)
sizer.Fit(self)
def OnCloseWindow(self, event):
self.Destroy()
class App(wx.App):
def OnInit(self):
frame = TestFrame(None, -1, "Sizer Test")
self.SetTopWindow(frame)
frame.Show(True)
return True
if __name__ == "__main__":
app = App(0)
app.MainLoop()