| 184 | # be plugged in based on column names |
| 185 | |
| 186 | class GridBase(Grid.Grid): |
| 187 | def __init__(self, parent): |
| 188 | Grid.Grid.__init__(self, parent, -1) |
| 189 | self.table = TableBase() |
| 190 | self.Bind(Grid.EVT_GRID_RANGE_SELECT, self.on_select) |
| 191 | self.Bind(wx.EVT_IDLE, self.on_idle) |
| 192 | self.tps = None |
| 193 | self.handle = None |
| 194 | self.Bind(Grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_label) |
| 195 | |
| 196 | def on_label(self, evt): |
| 197 | # Did we click on a row or a column? |
| 198 | row, col = evt.GetRow(), evt.GetCol() |
| 199 | if row==-1: |
| 200 | props = self.tps.props |
| 201 | |
| 202 | cur = props.iloc[:,col] |
| 203 | para = {'accu':cur[0], 'tc':cur[1], 'lc':cur[2], 'ln':cur[3]} |
| 204 | view = [(int, 'accu', (0, 10), 0, 'accuracy', ''), |
| 205 | ('color', 'tc', 'text color', ''), |
| 206 | ('color', 'lc', 'line color', ''), |
| 207 | (list, 'ln', ['Text', 'Line', 'Both'], str, 'draw', '')] |
| 208 | rst = IPy.get_para('Table Properties', view, para) |
| 209 | if not rst :return |
| 210 | if col!=-1: |
| 211 | props.iloc[:,col] = [para[i] for i in ['accu', 'tc', 'lc', 'ln']] |
| 212 | if col==-1: |
| 213 | for c in range(props.shape[1]): |
| 214 | props.iloc[:,c] = [para[i] for i in ['accu', 'tc', 'lc', 'ln']] |
| 215 | ''' |
| 216 | if row==-1 and col>-1: |
| 217 | props.ix['ln',col] = (props.ix['ln',col]+1)%3 |
| 218 | if row==-1 and col==-1: |
| 219 | cn = self.tps.data.columns[col] |
| 220 | props.ix['ln'] = (props.ix['ln'].min()+1)%3 |
| 221 | ''' |
| 222 | self.tps.update() |
| 223 | |
| 224 | |
| 225 | def set_handler(self, handle=None): |
| 226 | self.handle = handle |
| 227 | |
| 228 | def set_tps(self, tps): |
| 229 | self.tps = tps |
| 230 | self.table.set_tps(tps) |
| 231 | self._rows, self._cols = tps.data.shape |
| 232 | self.SetTable(self.table) |
| 233 | self.Reset() |
| 234 | |
| 235 | def on_select(self, event): |
| 236 | rs, cs = self.GetSelectedRows(), self.GetSelectedCols() |
| 237 | lt, rb = self.GetSelectionBlockTopLeft(), self.GetSelectionBlockBottomRight() |
| 238 | if len(lt)==1 and len(rb)==1: |
| 239 | return self.tps.select(range(lt[0][0],rb[0][0]+1), range(lt[0][1],rb[0][1]+1)) |
| 240 | else: self.tps.select(rs, cs, True) |
| 241 | #self.tps.select() |
| 242 | |
| 243 | def Reset(self): |