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