-
Notifications
You must be signed in to change notification settings - Fork 21
/
SizerTest.py
executable file
·141 lines (102 loc) · 5.26 KB
/
SizerTest.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python
import wx
class MainWindow(wx.Frame):
""" This window displays a button """
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent , -1, title)
self.List = map(str, range(10)) # just to get a list of text items
#Create a box inside to contain everything except the outputbox
# what's this for?
#innersizerbox =wx.BoxSizer(wx.HORIZONTAL)
#Create panel to contain other widgets (everything except the outputbox)
#use a panel if the widgets are logically grouped, but make a class for it in this case.
#self.panel = wx.Panel(self,-1,style=wx.ALIGN_BOTTOM|wx.ALIGN_CENTER)
#Create a flexsizer to contain other widgets (everything except the
#outputbox) need 2 rows and 9 columns
# 18 widgets?, I count ten. and you had rows and columns backward.
flexsizer= wx.FlexGridSizer(5, 2, 0, 0)
#Create a box to which to write output
self.outputbox = wx.TextCtrl(self, -1, "",size=wx.DefaultSize,
style=wx.TE_READONLY|wx.TE_WORDWRAP|wx.TE_MULTILINE)
self.file_input = wx.RadioButton(self, 31, label='Read input from file',
pos=(-1, -1))
self.gui_input = wx.RadioButton(self, 36, label='Select command below',
pos=(1, -1))
#wx.EVT_RADIOBUTTON(self, 31, self.SetMode)
#wx.EVT_RADIOBUTTON(self, 36, self.SetMode)
#was this ever used?
#radiosizer = wx.BoxSizer(wx.HORIZONTAL)
flexsizer.Add(self.file_input, 1, wx.ALL, 10)
flexsizer.Add(self.gui_input, 1, wx.EXPAND | wx.ALL, 15)
#Create combosizer which will contain the combobox and its label
combosizer = wx.BoxSizer(wx.HORIZONTAL)
#Create a Command Drop Down
self.combolabel = wx.StaticText(self,-1,"Please select a command:")
self.combo=wx.ComboBox(self, 30, " ",
wx.Point(wx.ALIGN_LEFT),
wx.DefaultSize,
self.List, wx.CB_DROPDOWN)
#wx.EVT_COMBOBOX(self, 30, self.CommandCallback)
combosizer.Add(self.combolabel, 1, wx.EXPAND | wx.ALL, 10)
combosizer.Add(self.combo, 2, wx.EXPAND | wx.ALL, 10)
flexsizer.Add(combosizer, 2, wx.EXPAND, 10)
#Create a box to accept parameters
self.parameterslabel = wx.StaticText(self, -1, "Enter parameters:")
self.parameters=wx.TextCtrl(self,-1,"", size=wx.DefaultSize)
parametersizer = wx.BoxSizer(wx.HORIZONTAL)
parametersizer.Add(self.parameterslabel, 0, wx.ALL, 10)
parametersizer.Add(self.parameters, 1, wx.ALL, 15)
flexsizer.Add(parametersizer,1,3,wx.ALL,10)
#Create button 1
self.buttonone = wx.Button(self, 32, label="ONE", style = wx.BU_BOTTOM,
size=(150, 20), name = "one")
self.buttonone.Bind(wx.EVT_BUTTON, self.OnButton)
#Create button 2
self.buttontwo = wx.Button(self, 33, label="TWO", style=wx.BU_BOTTOM,
size=(150, 20), name="two")
self.buttontwo.Bind(wx.EVT_BUTTON, self.OnButton)
#Create button 3
self.buttonthree = wx.Button(self, 34, label="THREE", style=wx.BU_BOTTOM,
size=(150, 20), name="three")
self.buttonthree.Bind(wx.EVT_BUTTON, self.OnButton)
#Create button 4
self.buttonfour = wx.Button(self, 35, label="FOUR", style=wx.BU_BOTTOM,
size=(150, 20), name="four")
self.buttonfour.Bind(wx.EVT_BUTTON, self.OnButton)
timeoutwarning=wx.StaticText(self, -1, 'Disable Timeouts Prior to Use')
flexsizer.Add(self.buttonone,4, wx.ALL | wx.ALIGN_RIGHT, 10)
flexsizer.Add(self.buttontwo, 5, wx.ALL | wx.ALIGN_RIGHT, 10)
flexsizer.Add(self.buttonthree, 6, wx.ALL | wx.ALIGN_RIGHT, 10)
flexsizer.Add(self.buttonfour, 8, wx.ALL | wx.ALIGN_RIGHT, 10)
flexsizer.Add(timeoutwarning, 9, wx.ALL | wx.ALIGN_BOTTOM, 10)
#Now add the output box and the flexgridsizer to the outerboxsize
#Create the outer sizer which is essentially the main window
# no, it's not a Window...it does do the layout for the main window.
# I like to build fromt eh inside out, so I put this here. It's really a matter of taste.
outerboxsizer = wx.BoxSizer(wx.VERTICAL)
outerboxsizer.Add(self.outputbox, 1, wx.EXPAND | wx.ALL, 10)
outerboxsizer.Add(flexsizer)
#Connect the outerboxsizer to the window (self)
self.SetSizer(outerboxsizer)
self.Fit()
self.Bind(wx.EVT_CLOSE, self.OnQuit)
def OnButton(self, event):
print(event.GetEventObject().GetLabel())
evtId = event.GetId()
if evtId == 32: print('1')
elif evtId == 33: print('2')
elif evtId == 34: print('3')
elif evtId == 35: print('4')
def SetMode(self):
pass
def OnQuit(self,Event):
self.Destroy()
class MyApp(wx.App):
def OnInit(self):
frame = MainWindow(None, -1, "Micro App")
self.SetTopWindow(frame)
frame.Show()
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()