1 |
jonathan |
372 |
# 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 |
|
|
from wxPython.wx import * |
13 |
|
|
from wxPython.grid import * |
14 |
|
|
|
15 |
jan |
374 |
from Thuban import _ |
16 |
|
|
|
17 |
jonathan |
372 |
ID_PROPERTY_SELECT = 4010 |
18 |
|
|
ID_CLASS_TABLE = 40011 |
19 |
|
|
|
20 |
|
|
ID_CLASSIFY_OK = 4001 |
21 |
|
|
ID_CLASSIFY_CANCEL = 4002 |
22 |
|
|
|
23 |
|
|
class Classifier(wxDialog): |
24 |
|
|
|
25 |
|
|
def __init__(self, parent, layer): |
26 |
jan |
374 |
wxDialog.__init__(self, parent, -1, _("Classify"), |
27 |
jonathan |
372 |
style = wxRESIZE_BORDER) |
28 |
|
|
|
29 |
|
|
topBox = wxBoxSizer(wxVERTICAL) |
30 |
|
|
|
31 |
|
|
propertyBox = wxBoxSizer(wxHORIZONTAL) |
32 |
jan |
374 |
propertyBox.Add(wxStaticText(self, -1, _("Property")), |
33 |
jonathan |
372 |
0, wxALIGN_CENTER | wxALL, 4) |
34 |
|
|
|
35 |
|
|
self.properties = wxComboBox(self, ID_PROPERTY_SELECT, "", |
36 |
|
|
style = wxCB_READONLY) |
37 |
|
|
|
38 |
|
|
self.num_cols = layer.table.field_count() |
39 |
|
|
for i in range(self.num_cols): |
40 |
|
|
type, name, len, decc = layer.table.field_info(i) |
41 |
|
|
self.properties.Append(name) |
42 |
|
|
|
43 |
|
|
propertyBox.Add(self.properties, 0, wxALL, 4) |
44 |
|
|
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect) |
45 |
|
|
|
46 |
|
|
topBox.Add(propertyBox, 0, 0) |
47 |
|
|
|
48 |
|
|
# |
49 |
|
|
# Classification data table |
50 |
|
|
# |
51 |
|
|
|
52 |
|
|
table = wxPyGridTableBase() |
53 |
|
|
tableBox = wxGridSizer(25) |
54 |
|
|
self.classTable = wxGrid(self, ID_CLASS_TABLE) |
55 |
|
|
self.classTable.CreateGrid(10, 2) |
56 |
|
|
self.classTable.SetTable(table, true) |
57 |
|
|
#table.SetNumberRows(10) |
58 |
|
|
#table.SetNumberCols(2) |
59 |
jan |
374 |
table.SetColLabelValue(0, _("Class")) |
60 |
|
|
table.SetColLabelValue(1, _("Value")) |
61 |
|
|
#self.classTable.SetColLabelValue(0, _("Class")) |
62 |
|
|
#self.classTable.SetColLabelValue(1, _("Value")) |
63 |
|
|
#self.classTable.SetCellValue(1, 1, _("Value")) |
64 |
jonathan |
372 |
|
65 |
|
|
tableBox.Add(self.classTable, 0, wxALL, 4) |
66 |
|
|
|
67 |
|
|
topBox.Add(self.classTable, 0, 0) |
68 |
|
|
|
69 |
|
|
# |
70 |
|
|
# Control buttons: |
71 |
|
|
# |
72 |
|
|
buttonBox = wxBoxSizer(wxHORIZONTAL) |
73 |
jan |
374 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")), |
74 |
jonathan |
372 |
0, wxALL, 4) |
75 |
jan |
374 |
buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")), |
76 |
jonathan |
372 |
0, wxALL, 4) |
77 |
|
|
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10) |
78 |
|
|
|
79 |
|
|
EVT_BUTTON(self, ID_CLASSIFY_OK, self.OnOK) |
80 |
|
|
EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self.OnCancel) |
81 |
|
|
|
82 |
|
|
self.SetAutoLayout(true) |
83 |
|
|
self.SetSizer(topBox) |
84 |
|
|
topBox.Fit(self) |
85 |
|
|
topBox.SetSizeHints(self) |
86 |
|
|
|
87 |
|
|
def OnPropertySelect(self, event): pass |
88 |
|
|
|
89 |
|
|
def OnOK(self, event): |
90 |
|
|
self.EndModal(wxID_OK) |
91 |
|
|
|
92 |
|
|
def OnCancel(self, event): |
93 |
|
|
self.EndModal(wxID_CANCEL) |
94 |
|
|
|