/[thuban]/trunk/thuban/Thuban/UI/classifier.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/UI/classifier.py

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

revision 372 by jonathan, Mon Jan 27 13:50:58 2003 UTC revision 376 by jonathan, Tue Jan 28 12:01:38 2003 UTC
# Line 9  Line 9 
9    
10  __version__ = "$Revision$"  __version__ = "$Revision$"
11    
12    import copy
13    
14  from wxPython.wx import *  from wxPython.wx import *
15  from wxPython.grid import *  from wxPython.grid import *
16    
17    from Thuban import _
18    
19  ID_PROPERTY_SELECT = 4010  ID_PROPERTY_SELECT = 4010
20  ID_CLASS_TABLE = 40011  ID_CLASS_TABLE = 40011
21    
22  ID_CLASSIFY_OK = 4001  ID_CLASSIFY_OK = 4001
23  ID_CLASSIFY_CANCEL = 4002  ID_CLASSIFY_CANCEL = 4002
24    
25    class ClassTable(wxPyGridTableBase):
26    
27        def __init__(self, clinfo):
28            wxPyGridTableBase.__init__(self)
29            self.clinfo = copy.deepcopy(clinfo)
30    
31            self.tdata = []
32    
33            for value, data in self.clinfo.points.items():
34                self.tdata.append([data, value])
35    
36            for range in self.clinfo.ranges:
37                self.tdata.append([range[2], '%s-%s' % range[0], range[1]])
38    
39            self.SetColLabelValue(1, "Data Values")
40    
41        def GetNumberRows(self):
42            return len(self.tdata)
43    
44        def GetNumberCols(self):
45            return 2
46    
47        def IsEmptyCell(self, row, col):
48            return false
49    
50        def GetValue(self, row, col):
51            return self.tdata[row][col]
52    
53        def SetValue(self, row, col, value):
54            pass
55        
56    
57    
58  class Classifier(wxDialog):  class Classifier(wxDialog):
59            
60      def __init__(self, parent, layer):      def __init__(self, parent, layer):
61          wxDialog.__init__(self, parent, -1, "Classify",          wxDialog.__init__(self, parent, -1, _("Classify"),
62                            style = wxRESIZE_BORDER)                            style = wxRESIZE_BORDER)
63    
64          topBox = wxBoxSizer(wxVERTICAL)          topBox = wxBoxSizer(wxVERTICAL)
65    
66          propertyBox = wxBoxSizer(wxHORIZONTAL)          propertyBox = wxBoxSizer(wxHORIZONTAL)
67          propertyBox.Add(wxStaticText(self, -1, "Property"),          propertyBox.Add(wxStaticText(self, -1, _("Property")),
68              0, wxALIGN_CENTER | wxALL, 4)              0, wxALIGN_CENTER | wxALL, 4)
69    
70          self.properties = wxComboBox(self, ID_PROPERTY_SELECT, "",          self.properties = wxComboBox(self, ID_PROPERTY_SELECT, "",
71                                       style = wxCB_READONLY)                                       style = wxCB_READONLY)
72    
73          self.num_cols = layer.table.field_count()          self.num_cols = layer.table.field_count()
74            cur_hilight = 0
75          for i in range(self.num_cols):          for i in range(self.num_cols):
76              type, name, len, decc = layer.table.field_info(i)              type, name, len, decc = layer.table.field_info(i)
77                if name == layer.classification.field:
78                    cur_hilight = i
79              self.properties.Append(name)              self.properties.Append(name)
80    
81          propertyBox.Add(self.properties, 0, wxALL, 4)          self.properties.SetSelection(cur_hilight)
82            propertyBox.Add(self.properties, 0, wxGROW, 4)
83          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect)          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect)
84    
85          topBox.Add(propertyBox, 0, 0)          topBox.Add(propertyBox, 0, wxGROW, 4)
86    
87          #          #
88          # Classification data table          # Classification data table
89          #          #
90    
91          table = wxPyGridTableBase()          self.classTable = wxGrid(self, ID_CLASS_TABLE, size=(300, 150))
92          tableBox = wxGridSizer(25)  
93          self.classTable = wxGrid(self, ID_CLASS_TABLE)          table = ClassTable(layer.classification)
         self.classTable.CreateGrid(10, 2)  
94          self.classTable.SetTable(table, true)          self.classTable.SetTable(table, true)
95    <<<<<<< classifier.py
96    
97            topBox.Add(self.classTable, 0, wxGROW, 0)
98    =======
99          #table.SetNumberRows(10)          #table.SetNumberRows(10)
100          #table.SetNumberCols(2)          #table.SetNumberCols(2)
101          table.SetColLabelValue(0, "Class")          table.SetColLabelValue(0, _("Class"))
102          table.SetColLabelValue(1, "Value")          table.SetColLabelValue(1, _("Value"))
103          #self.classTable.SetColLabelValue(0, "Class")          #self.classTable.SetColLabelValue(0, _("Class"))
104          #self.classTable.SetColLabelValue(1, "Value")          #self.classTable.SetColLabelValue(1, _("Value"))
105          #self.classTable.SetCellValue(1, 1, "Value")          #self.classTable.SetCellValue(1, 1, _("Value"))
106    
107          tableBox.Add(self.classTable, 0, wxALL, 4)          tableBox.Add(self.classTable, 0, wxALL, 4)
108                    
109          topBox.Add(self.classTable, 0, 0)          topBox.Add(self.classTable, 0, 0)
110    >>>>>>> 1.2
111    
112          #          #
113          # Control buttons:          # Control buttons:
114          #          #
115          buttonBox = wxBoxSizer(wxHORIZONTAL)          buttonBox = wxBoxSizer(wxHORIZONTAL)
116          buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, "OK"),          buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")),
117                        0, wxALL, 4)                        0, wxALL, 4)
118          buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, "Cancel"),          buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")),
119                        0, wxALL, 4)                        0, wxALL, 4)
120          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)
121    

Legend:
Removed from v.372  
changed lines
  Added in v.376

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26