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

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

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

revision 51 by bh, Tue Aug 28 15:41:52 2001 UTC revision 52 by bh, Mon Sep 10 16:05:13 2001 UTC
# Line 9  __version__ = "$Revision$" Line 9  __version__ = "$Revision$"
9    
10  from wxPython.wx import *  from wxPython.wx import *
11    
12    from controls import SelectableRecordListCtrl
13    
14  class LabelListCtrl(wxListCtrl):  class LabelListCtrl(SelectableRecordListCtrl):
15    
16      def __init__(self, parent, id, table, shape_index):      def __init__(self, parent, id, table, shape):
17          wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT)          SelectableRecordListCtrl.__init__(self, parent, id)
18            self.fill_list(table, shape)
         self.InsertColumn(0, "Field")  
         self.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)  
         self.InsertColumn(1, "Value")  
         self.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)  
   
         self.fill_list(table, shape_index)  
   
         self.selected = -1  
   
         EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected)  
   
     def fill_list(self, table, shape):  
         num_cols = table.field_count()  
         num_rows = table.record_count()  
   
         names = []  
         values = {}  
         for i in range(num_cols):  
             type, name, length, decc = table.field_info(i)  
             names.append(name)  
         record = table.read_record(shape)  
   
         for i in range(len(names)):  
             name = names[i]  
             value = record[name]  
             self.InsertStringItem(i, name)  
             self.SetStringItem(i, 1, str(value))  
             values[i] = value  
         self.values = values  
   
     def OnItemSelected(self, event):  
         self.selected = event.m_itemIndex  
   
     def GetValue(self):  
         if self.selected >= 0:  
             return self.values[self.selected]  
         else:  
             return ""  
19    
20    
21  class LabelDialog(wxDialog):  class LabelDialog(wxDialog):
# Line 85  class LabelDialog(wxDialog): Line 48  class LabelDialog(wxDialog):
48    
49      def OnOK(self, event):      def OnOK(self, event):
50          result = self.list.GetValue()          result = self.list.GetValue()
51          if result:          if result is not None:
52              self.end_dialog(wxID_OK, str(result))              self.end_dialog(wxID_OK, str(result))
53          else:          else:
54              self.end_dialog(wxID_CANCEL, None)                          self.end_dialog(wxID_CANCEL, None)            

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26