/[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 379 - (show annotations)
Tue Jan 28 12:54:01 2003 UTC (22 years, 1 month ago) by jonathan
File MIME type: text/x-python
File size: 3315 byte(s)
added i18n wrapper _() to text

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
96 topBox.Add(self.classTable, 0, wxGROW, 0)
97
98 #
99 # Control buttons:
100 #
101 buttonBox = wxBoxSizer(wxHORIZONTAL)
102 buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")),
103 0, wxALL, 4)
104 buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")),
105 0, wxALL, 4)
106 topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)
107
108 EVT_BUTTON(self, ID_CLASSIFY_OK, self.OnOK)
109 EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self.OnCancel)
110
111 self.SetAutoLayout(true)
112 self.SetSizer(topBox)
113 topBox.Fit(self)
114 topBox.SetSizeHints(self)
115
116 def OnPropertySelect(self, event): pass
117
118 def OnOK(self, event):
119 self.EndModal(wxID_OK)
120
121 def OnCancel(self, event):
122 self.EndModal(wxID_CANCEL)
123

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26