Run update-copyright.py.
[hooke.git] / hooke / ui / gui / dialog / string.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 import wx
19
20
21 class StringPopup (wx.Dialog):
22     def __init__(self):
23         self._c = {
24             'text': wx.StaticText(
25                 parent=self, label=message, style=wx.ALIGN_CENTRE),
26             'button': wx.Button(parent=self, id=button_id),
27             'cancel': wx.Button(self, wx.ID_CANCEL),
28             }
29         size = wx.Size(175, 200)
30         if selection_style == 'single':
31             self._c['listbox'] = wx.ListBox(
32                 parent=self, size=size, list=options)
33             if default != None:
34                 self._c['listbox'].SetSelection(default)
35         else:
36             assert selection_style == 'multiple', selection_style
37             self._c['listbox'] = wx.CheckListBox(
38                 parent=self, size=size, list=options)
39             if default != None:
40                 self._c['listbox'].Check(default)
41         self.Bind(wx.EVT_BUTTON, self.button, self._c['button'])
42         self.Bind(wx.EVT_BUTTON, self.cancel, self._c['cancel'])
43
44         border_width = 5
45
46         b = wx.BoxSizer(wx.HORIZONTAL)
47         b.Add(window=self._c['button'],
48               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,
49               border=border_width)
50         b.Add(window=self._c['cancel'],
51               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,
52               border=border_width)
53
54         v = wx.BoxSizer(wx.VERTICAL)
55         v.Add(window=self._c['text'],
56               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,
57               border=border_width)
58         v.Add(window=self._c['listbox'],
59               proportion=1,
60               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,
61               border=border_width)
62         v.Add(window=wx.StaticLine(
63                 parent=self, size=(20,-1), style=wx.LI_HORIZONTAL),
64               flag=wx.GROW,
65               border=border_width)
66         v.Add(window=b,
67               flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,
68               border=border_width)
69         self.SetSizer(v)
70         v.Fit(self)