1 | import wx |
---|
2 | import sys |
---|
3 | if sys.platform.count("win32") > 0: |
---|
4 | FONT_VARIANT = 0 |
---|
5 | PNL_WIDTH = 270 |
---|
6 | else: |
---|
7 | FONT_VARIANT = 1 |
---|
8 | PNL_WIDTH = 300 |
---|
9 | |
---|
10 | class LabelDialog(wx.Dialog): |
---|
11 | def __init__(self, parent, id, title, label): |
---|
12 | wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 150)) |
---|
13 | |
---|
14 | # Font |
---|
15 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
16 | mainbox = wx.BoxSizer(wx.VERTICAL) |
---|
17 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
18 | textbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
19 | |
---|
20 | text1 = "Enter a new title/label:" |
---|
21 | msg = wx.StaticText(self, -1, text1, (30, 15), style=wx.ALIGN_LEFT) |
---|
22 | msg.SetLabel(text1) |
---|
23 | self.label_ctrl = wx.TextCtrl(self, -1, '', (200, 30)) |
---|
24 | self.label_ctrl.SetValue(str(label)) |
---|
25 | textbox.Add(self.label_ctrl, flag=wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, |
---|
26 | border=10, proportion=2) |
---|
27 | vbox.Add(msg, flag=wx.ALL, border=10, proportion=1) |
---|
28 | vbox.Add(textbox, flag=wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, border=5) |
---|
29 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
30 | ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(70, 25)) |
---|
31 | close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(70, 25)) |
---|
32 | |
---|
33 | hbox.Add(ok_button, wx.LEFT, 10) |
---|
34 | hbox.Add((20, 20)) |
---|
35 | hbox.Add(close_button, wx.LEFT, 10) |
---|
36 | |
---|
37 | mainbox.Add(vbox, flag=wx.LEFT, border=5) |
---|
38 | mainbox.Add(wx.StaticLine(self), 0, wx.ALL | wx.EXPAND, 5) |
---|
39 | mainbox.Add(hbox, flag=wx.CENTER, border=20) |
---|
40 | self.SetSizer(mainbox) |
---|
41 | |
---|
42 | def getText(self): |
---|
43 | return self.label_ctrl.GetValue() |
---|