/[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 2239 - (show annotations)
Mon Jun 14 10:15:03 2004 UTC (20 years, 8 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/multiplechoicedialog.py
File MIME type: text/x-python
File size: 2394 byte(s)
(__version__): Add missing
import of wxPython.wx itself (as opposed to the contents of
wxPython.wx).  For some reason wxPython.wx is available as
wxPython.wx.wx in at least some 2.4 releases.  Fixes RT#2482
wrt. wxPython 2.4.

1 # Copyright (c) 2003, 2004 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 import wx
21 from wxPython.lib.layoutf import Layoutf
22
23 class wxMultipleChoiceDialog(wx.wxDialog):
24 """This is a copy of the class wxPython.lib.dialogs.wxMultipleChoiceDialog
25 and fixes the bug that the style now is passed on (this is fixed
26 in version wxPython 2.4.1).
27 """
28 def __init__(self, parent, msg, title, lst, pos = wxDefaultPosition,
29 size = (200,200), style = wxDEFAULT_DIALOG_STYLE):
30 wxDialog.__init__(self, parent, -1, title, pos, size, style)
31 x, y = pos
32 if x == -1 and y == -1:
33 self.CenterOnScreen(wx.wxBOTH)
34 dc = wx.wxClientDC(self)
35 height = 0
36 for line in msg.splitlines():
37 height = height + dc.GetTextExtent(msg)[1] + 4
38 stat = wx.wxStaticText(self, -1, msg)
39 self.lbox = wx.wxListBox(self, 100, wx.wxDefaultPosition,
40 wx.wxDefaultSize, lst, wx.wxLB_MULTIPLE)
41 ok = wx.wxButton(self, wx.wxID_OK, "OK")
42 cancel = wx.wxButton(self, wx.wxID_CANCEL, "Cancel")
43 stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
44 (self,)))
45 self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
46 (self, stat, ok)))
47 ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
48 cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
49 self.SetAutoLayout(1)
50 self.lst = lst
51 self.Layout()
52
53 def GetValue(self):
54 return self.lbox.GetSelections()
55
56 def GetValueString(self):
57 sel = self.lbox.GetSelections()
58 val = []
59 for i in sel:
60 val.append(self.lst[i])
61 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