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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2734 - (hide annotations)
Thu Mar 1 12:42:59 2007 UTC (18 years ago) by bramz
File MIME type: text/x-python
File size: 2314 byte(s)
made a copy
1 bh 2239 # Copyright (c) 2003, 2004 by Intevation GmbH
2 jan 1154 # 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 dpinte 2700 import wx
20 jan 1154
21 dpinte 2700 class wxMultipleChoiceDialog(wx.Dialog):
22 jan 1154 """This is a copy of the class wxPython.lib.dialogs.wxMultipleChoiceDialog
23     and fixes the bug that the style now is passed on (this is fixed
24     in version wxPython 2.4.1).
25     """
26 dpinte 2700 def __init__(self, parent, msg, title, lst, pos = wx.DefaultPosition,
27     size = (200,200), style = wx.DEFAULT_DIALOG_STYLE):
28     wx.Dialog.__init__(self, parent, -1, title, pos, size, style)
29 jan 1154 x, y = pos
30     if x == -1 and y == -1:
31     self.CenterOnScreen(wx.wxBOTH)
32     dc = wx.wxClientDC(self)
33     height = 0
34     for line in msg.splitlines():
35     height = height + dc.GetTextExtent(msg)[1] + 4
36     stat = wx.wxStaticText(self, -1, msg)
37     self.lbox = wx.wxListBox(self, 100, wx.wxDefaultPosition,
38     wx.wxDefaultSize, lst, wx.wxLB_MULTIPLE)
39     ok = wx.wxButton(self, wx.wxID_OK, "OK")
40     cancel = wx.wxButton(self, wx.wxID_CANCEL, "Cancel")
41     stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
42     (self,)))
43     self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
44     (self, stat, ok)))
45     ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
46     cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
47     self.SetAutoLayout(1)
48     self.lst = lst
49     self.Layout()
50    
51     def GetValue(self):
52     return self.lbox.GetSelections()
53    
54     def GetValueString(self):
55     sel = self.lbox.GetSelections()
56     val = []
57     for i in sel:
58     val.append(self.lst[i])
59     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