def __set_dev_grid(self): colourBackground = self.gridDev.GetLabelBackgroundColour() attributes = grid.GridCellAttr() attributes.SetBackgroundColour(colourBackground) self.gridDev.SetColAttr(self.COL_IND, attributes) self.gridDev.ClearGrid() i = 0 for device in self.devices: self.gridDev.SetReadOnly(i, self.COL_SEL, True) self.gridDev.SetReadOnly(i, self.COL_DEV, device.isDevice) self.gridDev.SetReadOnly(i, self.COL_TUN, True) self.gridDev.SetReadOnly(i, self.COL_SER, True) self.gridDev.SetReadOnly(i, self.COL_IND, True) self.gridDev.SetCellRenderer(i, self.COL_SEL, TickCellRenderer()) if device.isDevice: cell = grid.GridCellChoiceEditor(map(str, device.gains), allowOthers=False) self.gridDev.SetCellEditor(i, self.COL_GAIN, cell) self.gridDev.SetCellEditor(i, self.COL_CAL, grid.GridCellFloatEditor(-1, 3)) self.gridDev.SetCellEditor(i, self.COL_LO, grid.GridCellFloatEditor(-1, 3)) if device.isDevice: self.gridDev.SetCellValue(i, self.COL_DEV, device.name) self.gridDev.SetCellValue(i, self.COL_SER, str(device.serial)) self.gridDev.SetCellValue(i, self.COL_IND, str(i)) self.gridDev.SetCellBackgroundColour(i, self.COL_DEV, colourBackground) self.gridDev.SetCellValue(i, self.COL_GAIN, str(nearest(device.gain, device.gains))) else: self.gridDev.SetCellValue(i, self.COL_DEV, '{}:{}'.format(device.server, device.port)) self.gridDev.SetCellValue(i, self.COL_SER, '') self.gridDev.SetCellValue(i, self.COL_IND, '') self.gridDev.SetCellValue(i, self.COL_GAIN, str(device.gain)) self.gridDev.SetCellBackgroundColour(i, self.COL_SER, colourBackground) self.gridDev.SetCellValue(i, self.COL_TUN, TUNER[device.tuner]) self.gridDev.SetCellValue(i, self.COL_CAL, str(device.calibration)) self.gridDev.SetCellValue(i, self.COL_LO, str(device.lo)) self.gridDev.SetCellValue(i, self.COL_OFF, str(device.offset / 1e3)) i += 1 if self.settings.indexRtl >= len(self.devices): self.settings.indexRtl = len(self.devices) - 1 self.__select_row(self.settings.indexRtl) self.index = self.settings.indexRtl self.gridDev.AutoSize()
def __set_dev_grid(self): self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED) self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK) self.Unbind(grid.EVT_GRID_CELL_CHANGE) self.gridDev.ClearGrid() i = 0 for device in self.devices: self.gridDev.SetReadOnly(i, self.COL_SEL, True) self.gridDev.SetCellRenderer(i, self.COL_SEL, TickCellRenderer()) self.gridDev.SetCellValue(i, self.COL_NAME, device.name) cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE), allowOthers=False) self.gridDev.SetCellValue(i, self.COL_TYPE, DeviceGPS.TYPE[device.type]) self.gridDev.SetCellEditor(i, self.COL_TYPE, cell) if device.type == DeviceGPS.NMEA_SERIAL: self.gridDev.SetCellValue(i, self.COL_HOST, device.get_serial_desc()) self.gridDev.SetReadOnly(i, self.COL_HOST, True) else: self.gridDev.SetCellValue(i, self.COL_HOST, device.resource) self.gridDev.SetReadOnly(i, self.COL_HOST, False) self.gridDev.SetCellValue(i, self.COL_TEST, '...') self.gridDev.SetCellAlignment(i, self.COL_SEL, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) i += 1 self.index = limit(self.index, 0, len(self.devices) - 1) self.__select_row(self.index) self.index = self.index self.gridDev.AutoSize() font = self.gridDev.GetFont() dc = wx.WindowDC(self.gridDev) dc.SetFont(font) width, _height = dc.GetTextExtent(max(DeviceGPS.TYPE, key=len)) self.gridDev.SetColSize(self.COL_TYPE, width * 1.5) self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create) self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click) self.Bind(grid.EVT_GRID_CELL_CHANGE, self.__on_change)
def __set_grid(self): self.grid.DeleteRows(0, self.grid.GetNumberRows()) self.grid.AppendRows(len(self.backups.backups)) i = 0 for backup in self.backups.backups: self.grid.SetCellRenderer(i, self.COL_SEL, TickCellRenderer()) self.grid.SetCellRenderer(i, self.COL_TIME, GridCellDateTimeRenderer()) self.grid.SetReadOnly(i, self.COL_TIME, True) self.grid.SetReadOnly(i, self.COL_SIZE, True) self.grid.SetCellValue(i, self.COL_TIME, str(backup[1].replace(microsecond=0))) self.grid.SetCellValue(i, self.COL_SIZE, str(backup[2])) i += 1 self.__select_row(0) self.grid.AutoSize()