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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 376 - (show annotations)
Tue Jan 28 12:01:38 2003 UTC (22 years, 1 month ago) by jonathan
File MIME type: text/x-python
File size: 3784 byte(s)
fix i18n merge conflict

1 # Copyright (c) 2001 by Intevation GmbH
2 # Authors:
3 # Jonathan Coles <[email protected]>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with Thuban for details.
7
8 """Dialog for classifying how layers are displayed"""
9
10 __version__ = "$Revision$"
11
12 import copy
13
14 from wxPython.wx import *
15 from wxPython.grid import *
16
17 from Thuban import _
18
19 ID_PROPERTY_SELECT = 4010
20 ID_CLASS_TABLE = 40011
21
22 ID_CLASSIFY_OK = 4001
23 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):
59
60 def __init__(self, parent, layer):
61 wxDialog.__init__(self, parent, -1, _("Classify"),
62 style = wxRESIZE_BORDER)
63
64 topBox = wxBoxSizer(wxVERTICAL)
65
66 propertyBox = wxBoxSizer(wxHORIZONTAL)
67 propertyBox.Add(wxStaticText(self, -1, _("Property")),
68 0, wxALIGN_CENTER | wxALL, 4)
69
70 self.properties = wxComboBox(self, ID_PROPERTY_SELECT, "",
71 style = wxCB_READONLY)
72
73 self.num_cols = layer.table.field_count()
74 cur_hilight = 0
75 for i in range(self.num_cols):
76 type, name, len, decc = layer.table.field_info(i)
77 if name == layer.classification.field:
78 cur_hilight = i
79 self.properties.Append(name)
80
81 self.properties.SetSelection(cur_hilight)
82 propertyBox.Add(self.properties, 0, wxGROW, 4)
83 EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect)
84
85 topBox.Add(propertyBox, 0, wxGROW, 4)
86
87 #
88 # Classification data table
89 #
90
91 self.classTable = wxGrid(self, ID_CLASS_TABLE, size=(300, 150))
92
93 table = ClassTable(layer.classification)
94 self.classTable.SetTable(table, true)
95 <<<<<<< classifier.py
96
97 topBox.Add(self.classTable, 0, wxGROW, 0)
98 =======
99 #table.SetNumberRows(10)
100 #table.SetNumberCols(2)
101 table.SetColLabelValue(0, _("Class"))
102 table.SetColLabelValue(1, _("Value"))
103 #self.classTable.SetColLabelValue(0, _("Class"))
104 #self.classTable.SetColLabelValue(1, _("Value"))
105 #self.classTable.SetCellValue(1, 1, _("Value"))
106
107 tableBox.Add(self.classTable, 0, wxALL, 4)
108
109 topBox.Add(self.classTable, 0, 0)
110 >>>>>>> 1.2
111
112 #
113 # Control buttons:
114 #
115 buttonBox = wxBoxSizer(wxHORIZONTAL)
116 buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")),
117 0, wxALL, 4)
118 buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")),
119 0, wxALL, 4)
120 topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)
121
122 EVT_BUTTON(self, ID_CLASSIFY_OK, self.OnOK)
123 EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self.OnCancel)
124
125 self.SetAutoLayout(true)
126 self.SetSizer(topBox)
127 topBox.Fit(self)
128 topBox.SetSizeHints(self)
129
130 def OnPropertySelect(self, event): pass
131
132 def OnOK(self, event):
133 self.EndModal(wxID_OK)
134
135 def OnCancel(self, event):
136 self.EndModal(wxID_CANCEL)
137

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26