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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 52 - (hide annotations)
Mon Sep 10 16:05:13 2001 UTC (23 years, 6 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/labeldialog.py
File MIME type: text/x-python
File size: 2095 byte(s)
(LabelDialog.OnOK): Check whether the return value of GetValue is None
instead of using it as a boolean directly so that Zero numbers are
handled properly.
(LabelListCtrl): Derive from the new class SelectableRecordListCtrl

1 bh 6 # 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     from wxPython.wx import *
11    
12 bh 52 from controls import SelectableRecordListCtrl
13 bh 6
14 bh 52 class LabelListCtrl(SelectableRecordListCtrl):
15 bh 6
16 bh 52 def __init__(self, parent, id, table, shape):
17     SelectableRecordListCtrl.__init__(self, parent, id)
18     self.fill_list(table, shape)
19 bh 6
20    
21     class LabelDialog(wxDialog):
22    
23     def __init__(self, parent, table, shape_index):
24     wxDialog.__init__(self, parent, -1, "Label Values", wxDefaultPosition,
25     style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL)
26    
27     self.parent = parent
28     self.dialog_layout(table, shape_index)
29    
30     def dialog_layout(self, table, shape_index):
31     top_box = wxBoxSizer(wxVERTICAL)
32    
33     self.list = LabelListCtrl(self, -1, table, shape_index)
34     top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
35    
36     box = wxBoxSizer(wxHORIZONTAL)
37     box.Add(wxButton(self, wxID_OK, "OK"), 0, wxALL, 4)
38     box.Add(wxButton(self, wxID_CANCEL, "Cancel"), 0, wxALL, 4)
39     top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
40    
41     EVT_BUTTON(self, wxID_OK, self.OnOK)
42     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
43    
44     self.SetAutoLayout(true)
45     self.SetSizer(top_box)
46     top_box.Fit(self)
47     top_box.SetSizeHints(self)
48    
49     def OnOK(self, event):
50     result = self.list.GetValue()
51 bh 52 if result is not None:
52 bh 6 self.end_dialog(wxID_OK, str(result))
53     else:
54     self.end_dialog(wxID_CANCEL, None)
55    
56     def OnCancel(self, event):
57     self.end_dialog(wxID_CANCEL, None)
58    
59     def end_dialog(self, wx_result, result):
60     self.result = result
61     self.EndModal(wx_result)
62    
63     def run_label_dialog(parent, table, shape_index):
64     dialog = LabelDialog(parent, table, shape_index)
65     if dialog.ShowModal() == wxID_OK:
66     return dialog.result
67     else:
68     return None
69    

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26