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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2734 - (show annotations)
Thu Mar 1 12:42:59 2007 UTC (18 years ago) by bramz
File MIME type: text/x-python
File size: 2206 byte(s)
made a copy
1 # Copyright (c) 2001 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <[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 __version__ = "$Revision$"
9
10 import wx
11
12 from Thuban import _
13
14 from controls import SelectableRecordListCtrl
15
16 class LabelListCtrl(SelectableRecordListCtrl):
17
18 def __init__(self, parent, id, table, shape):
19 SelectableRecordListCtrl.__init__(self, parent, id)
20 self.fill_list(table, shape)
21
22
23 class LabelDialog(wx.Dialog):
24
25 def __init__(self, parent, table, shape_index):
26 wx.Dialog.__init__(self, parent, -1, _("Label Values"),
27 wx.DefaultPosition,
28 style = wx.RESIZE_BORDER|wx.CAPTION|wx.DIALOG_MODAL)
29
30 self.parent = parent
31 self.dialog_layout(table, shape_index)
32
33 def dialog_layout(self, table, shape_index):
34 top_box = wx.BoxSizer(wx.VERTICAL)
35
36 self.list = LabelListCtrl(self, -1, table, shape_index)
37 self.list.SetSize(wx.Size(305,200))
38 top_box.Add(self.list, 1, wx.EXPAND|wx.ALL, 4)
39
40 box = wx.BoxSizer(wx.HORIZONTAL)
41 box.Add(wx.Button(self, wx.ID_OK, _("OK")), 0, wx.ALL, 4)
42 box.Add(wx.Button(self, wx.ID_CANCEL, _("Cancel")), 0, wx.ALL, 4)
43 top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10)
44
45 self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
46 self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
47
48 self.SetAutoLayout(True)
49 self.SetSizer(top_box)
50 top_box.Fit(self)
51 top_box.SetSizeHints(self)
52
53 def OnOK(self, event):
54 result = self.list.GetValue()
55 if result is not None:
56 self.end_dialog(wx.ID_OK, str(result))
57 else:
58 self.end_dialog(wx.ID_CANCEL, None)
59
60 def OnCancel(self, event):
61 self.end_dialog(wx.ID_CANCEL, None)
62
63 def end_dialog(self, wx_result, result):
64 self.result = result
65 self.EndModal(wx_result)
66
67 def run_label_dialog(parent, table, shape_index):
68 dialog = LabelDialog(parent, table, shape_index)
69 if dialog.ShowModal() == wx.ID_OK:
70 return dialog.result
71 else:
72 return None
73

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26