1 | import wx |
---|
2 | |
---|
3 | |
---|
4 | class SizeDialog(wx.Dialog): |
---|
5 | def __init__(self, parent, id, title): |
---|
6 | wx.Dialog.__init__(self, parent, id, title, size=(300, 175)) |
---|
7 | |
---|
8 | mainbox = wx.BoxSizer(wx.VERTICAL) |
---|
9 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
10 | textbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
11 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
12 | text1 = "Enter in a custom size (> 0 accepted)" |
---|
13 | msg = wx.StaticText(self, -1, text1, (30, 15), style=wx.ALIGN_CENTRE) |
---|
14 | msg.SetLabel(text1) |
---|
15 | self.text_ctrl = wx.TextCtrl(self, -1, '', (100, 50)) |
---|
16 | |
---|
17 | textbox.Add(self.text_ctrl, flag=wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, border=10) |
---|
18 | vbox.Add(msg, flag=wx.ALL, border=10, proportion=1) |
---|
19 | vbox.Add(textbox, flag=wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, border=10) |
---|
20 | self.text_ctrl.SetValue(str(5)) |
---|
21 | |
---|
22 | ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(70, 25)) |
---|
23 | close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(70, 25)) |
---|
24 | |
---|
25 | hbox.Add(ok_button) |
---|
26 | hbox.Add((20, 20)) |
---|
27 | hbox.Add(close_button) |
---|
28 | |
---|
29 | mainbox.Add(vbox, flag=wx.ALL, border=10) |
---|
30 | mainbox.Add(wx.StaticLine(self), 0, wx.ALL | wx.EXPAND, 5) |
---|
31 | mainbox.Add(hbox, flag=wx.CENTER, border=10) |
---|
32 | self.SetSizer(mainbox) |
---|
33 | |
---|
34 | def getText(self): |
---|
35 | """ |
---|
36 | Get text typed |
---|
37 | """ |
---|
38 | return self.text_ctrl.GetValue() |
---|