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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1968 - (show 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 # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <[email protected]>
4 # Frank Koormann <[email protected]>
5 #
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 from Thuban import _
15
16 from dialogs import NonModalDialog
17 from controls import RecordListCtrl, RecordGridCtrl
18 from messages import SHAPES_SELECTED
19 import main
20
21 class IdentifyListCtrl(RecordListCtrl):
22
23 def selected_shape(self, layer, shape):
24 if layer is not None:
25 table = layer.ShapeStore().Table()
26 else:
27 table = None
28 self.fill_list(table, shape)
29
30 class IdentifyGridCtrl(RecordGridCtrl):
31
32 def selected_shape(self, layer, shape):
33 if layer is not None:
34 table = layer.ShapeStore().Table()
35 else:
36 table = None
37 self.SetTableRecord(table, shape)
38
39 class IdentifyView(NonModalDialog):
40
41 ID_STOP = 100
42
43 def __init__(self, parent, name):
44 NonModalDialog.__init__(self, parent, name, _("Identify Shape"))
45 parent.Subscribe(SHAPES_SELECTED, self.selected_shape)
46
47 top_box = wxBoxSizer(wxVERTICAL)
48 if main.options.attribute_editing_enabled:
49 self.list = IdentifyGridCtrl(self)
50 else:
51 self.list = IdentifyListCtrl(self, -1)
52 self.list.SetSize(wxSize(305,200))
53 top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
54
55 box = wxBoxSizer(wxHORIZONTAL)
56 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 top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4)
60
61 EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
62 EVT_BUTTON(self, self.ID_STOP, self.OnStop)
63
64 self.SetAutoLayout(True)
65 self.SetSizer(top_box)
66 top_box.Fit(self)
67 top_box.SetSizeHints(self)
68
69 # Make sure to reflect the current selection.
70 self.selected_shape(parent.SelectedLayer(), parent.SelectedShapes())
71
72 def OnClose(self, event):
73 self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape)
74 NonModalDialog.OnClose(self, event)
75
76 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 def selected_shape(self, layer, shapes):
82 """Subscribed to the SHAPES_SELECTED messages.
83
84 If exactly one shape is selected, pass that shape id to the
85 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 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