/[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 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 374 by jan, Mon Jan 27 14:20:02 2003 UTC
# Line 9  __version__ = "$Revision$" Line 9  __version__ = "$Revision$"
9    
10  from wxPython.wx import *  from wxPython.wx import *
11    
12    from Thuban import _
13    
14  class LabelListCtrl(wxListCtrl):  from controls import SelectableRecordListCtrl
15    
16      def __init__(self, parent, id, table, shape_index):  class LabelListCtrl(SelectableRecordListCtrl):
         wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT)  
17    
18          self.InsertColumn(0, "Field")      def __init__(self, parent, id, table, shape):
19          self.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)          SelectableRecordListCtrl.__init__(self, parent, id)
20          self.InsertColumn(1, "Value")          self.fill_list(table, shape)
         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 ""  
21    
22    
23  class LabelDialog(wxDialog):  class LabelDialog(wxDialog):
24    
25      def __init__(self, parent, table, shape_index):      def __init__(self, parent, table, shape_index):
26          wxDialog.__init__(self, parent, -1, "Label Values", wxDefaultPosition,          wxDialog.__init__(self, parent, -1, _("Label Values"),
27                              wxDefaultPosition,
28                            style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL)                            style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL)
29    
30          self.parent = parent          self.parent = parent
# Line 71  class LabelDialog(wxDialog): Line 37  class LabelDialog(wxDialog):
37          top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)          top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
38    
39          box = wxBoxSizer(wxHORIZONTAL)          box = wxBoxSizer(wxHORIZONTAL)
40          box.Add(wxButton(self, wxID_OK, "OK"), 0, wxALL, 4)          box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4)
41          box.Add(wxButton(self, wxID_CANCEL, "Cancel"), 0, wxALL, 4)          box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4)
42          top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)          top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
43    
44          EVT_BUTTON(self, wxID_OK, self.OnOK)          EVT_BUTTON(self, wxID_OK, self.OnOK)
# Line 85  class LabelDialog(wxDialog): Line 51  class LabelDialog(wxDialog):
51    
52      def OnOK(self, event):      def OnOK(self, event):
53          result = self.list.GetValue()          result = self.list.GetValue()
54          if result:          if result is not None:
55              self.end_dialog(wxID_OK, str(result))              self.end_dialog(wxID_OK, str(result))
56          else:          else:
57              self.end_dialog(wxID_CANCEL, None)                          self.end_dialog(wxID_CANCEL, None)            

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26