/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/multiplechoicedialog.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/Thuban/UI/multiplechoicedialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1154 - (show annotations)
Thu Jun 12 12:14:19 2003 UTC (21 years, 8 months ago) by jan
Original Path: trunk/thuban/Thuban/UI/multiplechoicedialog.py
File MIME type: text/x-python
File size: 2364 byte(s)
A multiple choice dialog.

1 # Copyright (c) 2003 by Intevation GmbH
2 # Authors:
3 # Jan-Oliver Wagner <[email protected]>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with Thuban for details.
7
8 """A dialog for entering multiple choice from a list of strings.
9
10 This dialog is actually a class contained by the wxPython Library.
11 However, the wxMultipleChoiceDialog did not pass the style in 2.4.0.
12
13 As soon as Thuban does not support wxPython 2.4.0 any more,
14 this module can be removed and the official wxMultipleChoiceDialog
15 of the wxPython Library be used directly."""
16
17 __version__ = "$Revision$"
18
19 from wxPython.wx import *
20 from wxPython.lib.layoutf import Layoutf
21
22 class wxMultipleChoiceDialog(wx.wxDialog):
23 """This is a copy of the class wxPython.lib.dialogs.wxMultipleChoiceDialog
24 and fixes the bug that the style now is passed on (this is fixed
25 in version wxPython 2.4.1).
26 """
27 def __init__(self, parent, msg, title, lst, pos = wxDefaultPosition,
28 size = (200,200), style = wxDEFAULT_DIALOG_STYLE):
29 wxDialog.__init__(self, parent, -1, title, pos, size, style)
30 x, y = pos
31 if x == -1 and y == -1:
32 self.CenterOnScreen(wx.wxBOTH)
33 dc = wx.wxClientDC(self)
34 height = 0
35 for line in msg.splitlines():
36 height = height + dc.GetTextExtent(msg)[1] + 4
37 stat = wx.wxStaticText(self, -1, msg)
38 self.lbox = wx.wxListBox(self, 100, wx.wxDefaultPosition,
39 wx.wxDefaultSize, lst, wx.wxLB_MULTIPLE)
40 ok = wx.wxButton(self, wx.wxID_OK, "OK")
41 cancel = wx.wxButton(self, wx.wxID_CANCEL, "Cancel")
42 stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
43 (self,)))
44 self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
45 (self, stat, ok)))
46 ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
47 cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
48 self.SetAutoLayout(1)
49 self.lst = lst
50 self.Layout()
51
52 def GetValue(self):
53 return self.lbox.GetSelections()
54
55 def GetValueString(self):
56 sel = self.lbox.GetSelections()
57 val = []
58 for i in sel:
59 val.append(self.lst[i])
60 return tuple(val)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26