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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1968 - (hide annotations)
Fri Nov 21 14:33:27 2003 UTC (21 years, 3 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/identifyview.py
File MIME type: text/x-python
File size: 2912 byte(s)
Enable the experimental attribute editing again and introduce a
command line switch to actually activate it

* Thuban/UI/main.py (options): New. Container for options set on
the commmand line
(main): Add the --enable-attribute-editing flag.

* Thuban/UI/identifyview.py (IdentifyView.__init__): If attribute
editing is enabled use the grid ctrl which allows editing of the
values

* Thuban/Model/transientdb.py (AutoTransientTable.write_record):
New. Just delegate this to the underlying table.

1 bh 535 # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2 bh 6 # Authors:
3     # Bernhard Herzog <[email protected]>
4 frank 1138 # Frank Koormann <[email protected]>
5 bh 6 #
6     # This program is free software under the GPL (>=v2)
7     # Read the file COPYING coming with Thuban for details.
8    
9     __version__ = "$Revision$"
10    
11     from wxPython.wx import *
12     from wxPython.grid import *
13    
14 jan 374 from Thuban import _
15    
16 bh 29 from dialogs import NonModalDialog
17 bh 80 from controls import RecordListCtrl, RecordGridCtrl
18 bh 535 from messages import SHAPES_SELECTED
19 bh 1968 import main
20 bh 6
21 bh 51 class IdentifyListCtrl(RecordListCtrl):
22 bh 6
23     def selected_shape(self, layer, shape):
24 bh 66 if layer is not None:
25 bh 1219 table = layer.ShapeStore().Table()
26 bh 66 else:
27     table = None
28     self.fill_list(table, shape)
29 bh 6
30 bh 80 class IdentifyGridCtrl(RecordGridCtrl):
31 bh 6
32 bh 80 def selected_shape(self, layer, shape):
33     if layer is not None:
34 bh 1219 table = layer.ShapeStore().Table()
35 bh 80 else:
36     table = None
37     self.SetTableRecord(table, shape)
38    
39 bh 29 class IdentifyView(NonModalDialog):
40 bh 6
41 jan 1706 ID_STOP = 100
42    
43 bh 535 def __init__(self, parent, name):
44     NonModalDialog.__init__(self, parent, name, _("Identify Shape"))
45     parent.Subscribe(SHAPES_SELECTED, self.selected_shape)
46    
47 frank 1138 top_box = wxBoxSizer(wxVERTICAL)
48 bh 1968 if main.options.attribute_editing_enabled:
49     self.list = IdentifyGridCtrl(self)
50     else:
51     self.list = IdentifyListCtrl(self, -1)
52 frank 1138 self.list.SetSize(wxSize(305,200))
53     top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
54 bh 6
55 frank 1138 box = wxBoxSizer(wxHORIZONTAL)
56 jan 1706 box.Add(wxButton(self, wxID_CLOSE, _("Close Window")), 0, wxALL, 4)
57     box.Add(wxButton(self, self.ID_STOP, _("Stop Identify Mode")),
58     0, wxALL, 4)
59 frank 1138 top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4)
60 bh 535
61 frank 1138 EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
62 jan 1706 EVT_BUTTON(self, self.ID_STOP, self.OnStop)
63 bh 29
64 frank 1138 self.SetAutoLayout(True)
65     self.SetSizer(top_box)
66     top_box.Fit(self)
67     top_box.SetSizeHints(self)
68    
69 bh 1194 # Make sure to reflect the current selection.
70     self.selected_shape(parent.SelectedLayer(), parent.SelectedShapes())
71    
72 bh 29 def OnClose(self, event):
73 bh 535 self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape)
74 bh 29 NonModalDialog.OnClose(self, event)
75    
76 jan 1706 def OnStop(self, event):
77     self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape)
78     self.parent.canvas.SelectTool(None)
79     NonModalDialog.OnClose(self, event)
80    
81 bh 535 def selected_shape(self, layer, shapes):
82     """Subscribed to the SHAPES_SELECTED messages.
83    
84 bh 1950 If exactly one shape is selected, pass that shape id to the
85 bh 535 list's selected_shape method. Otherwise pass None as the shape
86     id.
87     """
88     if len(shapes) == 1:
89     shape = shapes[0]
90     else:
91     shape = None
92 bh 29 self.list.selected_shape(layer, shape)

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26