119 |
#self.AutoSizeColumns(false) |
#self.AutoSizeColumns(false) |
120 |
|
|
121 |
self.SetSelectionMode(wxGrid.wxGridSelectRows) |
self.SetSelectionMode(wxGrid.wxGridSelectRows) |
122 |
|
|
123 |
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
124 |
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
125 |
|
|
133 |
def OnSelectCell(self, event): |
def OnSelectCell(self, event): |
134 |
self.issue(ROW_SELECTED, event.GetRow()) |
self.issue(ROW_SELECTED, event.GetRow()) |
135 |
|
|
136 |
|
|
137 |
|
class LayerTableGrid(TableGrid): |
138 |
|
|
139 |
|
"""Table grid for the layer tables. |
140 |
|
|
141 |
|
The LayerTableGrid is basically the same as a TableGrid but it's |
142 |
|
selection is usually coupled to the selected object in the map. |
143 |
|
""" |
144 |
|
|
145 |
def select_shape(self, layer, shape): |
def select_shape(self, layer, shape): |
146 |
|
"""Select the row corresponding to the specified shape and layer |
147 |
|
|
148 |
|
If layer is not the layer the table is associated with do |
149 |
|
nothing. If shape or layer is None also do nothing. |
150 |
|
""" |
151 |
|
print "LayerTableGrid.select_shape", layer, shape |
152 |
if layer is not None and layer.table is self.table.table \ |
if layer is not None and layer.table is self.table.table \ |
153 |
and shape is not None: |
and shape is not None: |
154 |
self.SelectRow(shape) |
self.SelectRow(shape) |
160 |
|
|
161 |
"""Frame that displays a Thuban table in a grid view""" |
"""Frame that displays a Thuban table in a grid view""" |
162 |
|
|
163 |
def __init__(self, parent, interactor, name, title, layer = None, |
def __init__(self, parent, interactor, name, title, table): |
|
table = None): |
|
164 |
NonModalDialog.__init__(self, parent, interactor, name, title) |
NonModalDialog.__init__(self, parent, interactor, name, title) |
|
self.layer = layer |
|
165 |
self.table = table |
self.table = table |
166 |
self.grid = TableGrid(self, table) |
self.grid = self.make_grid(self.table) |
167 |
|
|
168 |
|
def make_grid(self, table): |
169 |
|
"""Return the table grid to use in the frame. |
170 |
|
|
171 |
|
The default implementation returns a TableGrid instance. |
172 |
|
Override in derived classes to use different grid classes. |
173 |
|
""" |
174 |
|
return TableGrid(self, table) |
175 |
|
|
176 |
|
|
177 |
|
class LayerTableFrame(TableFrame): |
178 |
|
|
179 |
|
"""Frame that displays a layer table in a grid view |
180 |
|
|
181 |
|
A LayerTableFrame is TableFrame whose selection is connected to the |
182 |
|
selected object in a map. |
183 |
|
""" |
184 |
|
|
185 |
|
def __init__(self, parent, interactor, name, title, layer, table): |
186 |
|
TableFrame.__init__(self, parent, interactor, name, title, table) |
187 |
|
self.layer = layer |
188 |
self.grid.Subscribe(ROW_SELECTED, self.row_selected) |
self.grid.Subscribe(ROW_SELECTED, self.row_selected) |
189 |
self.interactor.Subscribe(SELECTED_SHAPE, self.select_shape) |
self.interactor.Subscribe(SELECTED_SHAPE, self.select_shape) |
190 |
|
|
191 |
|
def make_grid(self, table): |
192 |
|
"""Override the derived method to return a LayerTableGrid. |
193 |
|
""" |
194 |
|
return LayerTableGrid(self, table) |
195 |
|
|
196 |
def OnClose(self, event): |
def OnClose(self, event): |
197 |
self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
198 |
NonModalDialog.OnClose(self, event) |
TableFrame.OnClose(self, event) |
199 |
|
|
200 |
def select_shape(self, layer, shape): |
def select_shape(self, layer, shape): |
201 |
self.grid.select_shape(layer, shape) |
self.grid.select_shape(layer, shape) |