/[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 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 51 by bh, Mon Sep 10 16:04:43 2001 UTC
# Line 11  from wxPython.wx import * Line 11  from wxPython.wx import *
11  from wxPython.grid import *  from wxPython.grid import *
12    
13  import view  import view
14    from dialogs import NonModalDialog
15    from controls import RecordListCtrl
16  from messages import SELECTED_SHAPE  from messages import SELECTED_SHAPE
17    
18  class IdentifyListCtrl(wxListCtrl):  class IdentifyListCtrl(RecordListCtrl):
   
     def __init__(self, parent, id, interactor):  
         wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT)  
         self.interactor = interactor  
         self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape)  
   
         self.InsertColumn(0, "Field")  
         self.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)  
         self.InsertColumn(1, "Value")  
         self.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)  
   
     def fill_list(self, layer, shape):  
         self.DeleteAllItems()  
   
         if shape is not None:  
             table = layer.shapetable  
             num_cols = table.field_count()  
             num_rows = table.record_count()  
               
             names = []  
             for i in range(num_cols):  
                 type, name, length, decc = table.field_info(i)  
                 names.append(name)  
             record = table.read_record(shape)  
             i = 0  
             for name in names:  
                 value = record[name]  
                 i = self.InsertStringItem(i, name)  
                 self.SetStringItem(i, 1, str(value))  
19    
20      def selected_shape(self, layer, shape):      def selected_shape(self, layer, shape):
21          self.fill_list(layer, shape)          self.fill_list(layer.shapetable, shape)
               
22    
23    
24  class IdentifyView(wxFrame):  class IdentifyView(NonModalDialog):
25    
26      def __init__(self, parent, app):      def __init__(self, parent, interactor, name):
27          # assume parent is Thuban's main window python object          NonModalDialog.__init__(self, parent, interactor, name,
28          wxFrame.__init__(self, parent, -1, "Identify Shape")                                  "Identify Shape")
29            self.interactor.Subscribe(SELECTED_SHAPE, self.selected_shape)
30            
31          panel = wxPanel(self, -1, style = wxWANTS_CHARS)          panel = wxPanel(self, -1, style = wxWANTS_CHARS)
32          self.list = IdentifyListCtrl(panel, -1, app.interactor)          self.list = IdentifyListCtrl(panel, -1)
33    
34          sizer = wxBoxSizer(wxVERTICAL)          sizer = wxBoxSizer(wxVERTICAL)
35          sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)          sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)
# Line 63  class IdentifyView(wxFrame): Line 37  class IdentifyView(wxFrame):
37          panel.SetAutoLayout(true)          panel.SetAutoLayout(true)
38          panel.SetSizer(sizer)          panel.SetSizer(sizer)
39          sizer.Fit(panel)          sizer.Fit(panel)
40    
41        def OnClose(self, event):
42            self.interactor.Unsubscribe(SELECTED_SHAPE, self.selected_shape)
43            NonModalDialog.OnClose(self, event)
44    
45        def selected_shape(self, layer, shape):
46            self.list.selected_shape(layer, shape)

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26