/[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 29 - (hide annotations)
Thu Sep 6 13:30:59 2001 UTC (23 years, 6 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/identifyview.py
File MIME type: text/x-python
File size: 2244 byte(s)
(IdentifyListCtrl.__init__): Remove the interactor argument. The
SELECTED_SHAPE message is now handled by the parent.

(IdentifyView.__init__): Add the interactor argument so that we can
handle the SELECTED_SHAPE message here

(IdentifyView.selected_shape): New method to handle the SELECTED_SHAPE
messages

(IdentifyView): Derive from the new NonModalDialog class
(IdentifyView.OnClose): Extend the inherited version to unsubscribe
SELECT_SHAPE

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     from wxPython.grid import *
12    
13     import view
14 bh 29 from dialogs import NonModalDialog
15 bh 6 from messages import SELECTED_SHAPE
16    
17     class IdentifyListCtrl(wxListCtrl):
18    
19 bh 29 def __init__(self, parent, id):
20 bh 6 wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT)
21    
22     self.InsertColumn(0, "Field")
23     self.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)
24     self.InsertColumn(1, "Value")
25     self.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)
26    
27     def fill_list(self, layer, shape):
28     self.DeleteAllItems()
29    
30     if shape is not None:
31     table = layer.shapetable
32     num_cols = table.field_count()
33     num_rows = table.record_count()
34    
35     names = []
36     for i in range(num_cols):
37     type, name, length, decc = table.field_info(i)
38     names.append(name)
39     record = table.read_record(shape)
40     i = 0
41     for name in names:
42     value = record[name]
43     i = self.InsertStringItem(i, name)
44     self.SetStringItem(i, 1, str(value))
45    
46     def selected_shape(self, layer, shape):
47     self.fill_list(layer, shape)
48    
49    
50    
51 bh 29 class IdentifyView(NonModalDialog):
52 bh 6
53 bh 29 def __init__(self, parent, interactor, name):
54     NonModalDialog.__init__(self, parent, interactor, name,
55     "Identify Shape")
56     self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape)
57    
58 bh 6 panel = wxPanel(self, -1, style = wxWANTS_CHARS)
59 bh 29 self.list = IdentifyListCtrl(panel, -1)
60 bh 6
61     sizer = wxBoxSizer(wxVERTICAL)
62     sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)
63    
64     panel.SetAutoLayout(true)
65     panel.SetSizer(sizer)
66     sizer.Fit(panel)
67 bh 29
68     def OnClose(self, event):
69     self.interactor.Unsubscribe(SELECTED_SHAPE, self.selected_shape)
70     NonModalDialog.OnClose(self, event)
71    
72     def selected_shape(self, layer, shape):
73     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