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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 51 by bh, Mon Sep 10 16:04:43 2001 UTC revision 535 by bh, Fri Mar 14 20:42:18 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 by Intevation GmbH  # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 10  __version__ = "$Revision$" Line 10  __version__ = "$Revision$"
10  from wxPython.wx import *  from wxPython.wx import *
11  from wxPython.grid import *  from wxPython.grid import *
12    
13  import view  from Thuban import _
14    
15  from dialogs import NonModalDialog  from dialogs import NonModalDialog
16  from controls import RecordListCtrl  from controls import RecordListCtrl, RecordGridCtrl
17  from messages import SELECTED_SHAPE  from messages import SHAPES_SELECTED
18    
19  class IdentifyListCtrl(RecordListCtrl):  class IdentifyListCtrl(RecordListCtrl):
20    
21      def selected_shape(self, layer, shape):      def selected_shape(self, layer, shape):
22          self.fill_list(layer.shapetable, shape)          if layer is not None:
23                table = layer.shapetable
24            else:
25                table = None
26            self.fill_list(table, shape)
27    
28    class IdentifyGridCtrl(RecordGridCtrl):
29    
30        def selected_shape(self, layer, shape):
31            if layer is not None:
32                table = layer.shapetable
33            else:
34                table = None
35            self.SetTableRecord(table, shape)
36    
37  class IdentifyView(NonModalDialog):  class IdentifyView(NonModalDialog):
38    
39      def __init__(self, parent, interactor, name):      def __init__(self, parent, name):
40          NonModalDialog.__init__(self, parent, interactor, name,          NonModalDialog.__init__(self, parent, name, _("Identify Shape"))
41                                  "Identify Shape")          parent.Subscribe(SHAPES_SELECTED, self.selected_shape)
42          self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape)  
           
43          panel = wxPanel(self, -1, style = wxWANTS_CHARS)          panel = wxPanel(self, -1, style = wxWANTS_CHARS)
44          self.list = IdentifyListCtrl(panel, -1)          #self.list = IdentifyListCtrl(panel, -1)
45            self.list = IdentifyGridCtrl(panel)
46    
47          sizer = wxBoxSizer(wxVERTICAL)          sizer = wxBoxSizer(wxVERTICAL)
48          sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)          sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)
49    
50            self.SetSize(wxSize(300,200))
51          panel.SetAutoLayout(true)          panel.SetAutoLayout(true)
52          panel.SetSizer(sizer)          panel.SetSizer(sizer)
53          sizer.Fit(panel)          sizer.Fit(panel)
54    
55      def OnClose(self, event):      def OnClose(self, event):
56          self.interactor.Unsubscribe(SELECTED_SHAPE, self.selected_shape)          self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape)
57          NonModalDialog.OnClose(self, event)          NonModalDialog.OnClose(self, event)
58    
59      def selected_shape(self, layer, shape):      def selected_shape(self, layer, shapes):
60            """Subscribed to the SHAPES_SELECTED messages.
61    
62            If exatly one shape is selected, pass that shape id to the
63            list's selected_shape method. Otherwise pass None as the shape
64            id.
65            """
66            if len(shapes) == 1:
67                shape = shapes[0]
68            else:
69                shape = None
70          self.list.selected_shape(layer, shape)          self.list.selected_shape(layer, shape)

Legend:
Removed from v.51  
changed lines
  Added in v.535

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26