13 |
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \ |
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \ |
14 |
FIELDTYPE_STRING |
FIELDTYPE_STRING |
15 |
import view |
import view |
16 |
|
from dialogs import NonModalDialog |
17 |
from messages import SELECTED_SHAPE |
from messages import SELECTED_SHAPE |
18 |
|
|
19 |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
96 |
return interactor.SelectShape(self.table, row) |
return interactor.SelectShape(self.table, row) |
97 |
|
|
98 |
|
|
|
|
|
|
|
|
|
|
|
99 |
class TableGrid(wxGrid): |
class TableGrid(wxGrid): |
100 |
|
|
101 |
def __init__(self, parent, table = None): |
def __init__(self, parent, table = None): |
116 |
|
|
117 |
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
118 |
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
|
import main |
|
|
main.app.interactor.Subscribe(SELECTED_SHAPE, self.select_shape) |
|
119 |
|
|
120 |
def SetTableObject(self, table): |
def SetTableObject(self, table): |
121 |
self.table.SetTable(table) |
self.table.SetTable(table) |
130 |
event.Skip() |
event.Skip() |
131 |
|
|
132 |
def select_shape(self, layer, shape): |
def select_shape(self, layer, shape): |
133 |
if layer is not None and layer.table is self.table.table: |
if layer is not None and layer.table is self.table.table \ |
134 |
|
and shape is not None: |
135 |
self.SelectRow(shape) |
self.SelectRow(shape) |
136 |
self.SetGridCursor(shape, 0) |
self.SetGridCursor(shape, 0) |
137 |
self.MakeCellVisible(shape, 0) |
self.MakeCellVisible(shape, 0) |
138 |
|
|
139 |
|
|
140 |
class TableFrame(wxFrame): |
class TableFrame(NonModalDialog): |
141 |
|
|
142 |
def __init__(self, parent, table = None): |
def __init__(self, parent, interactor, name, title, table = None): |
143 |
wxFrame.__init__(self, parent, -1, "Thuban Table") |
NonModalDialog.__init__(self, parent, interactor, name, title) |
144 |
grid = TableGrid(self, table) |
self.grid = TableGrid(self, table) |
145 |
|
self.interactor.Subscribe(SELECTED_SHAPE, self.select_shape) |
146 |
|
|
147 |
|
def OnClose(self, event): |
148 |
|
self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
149 |
|
NonModalDialog.OnClose(self, event) |
150 |
|
|
151 |
|
def select_shape(self, layer, shape): |
152 |
|
self.grid.select_shape(layer, shape) |