def _onAddSetup(self, event: wx.grid.GridEvent): setup = Setup(name=event.GetString()) self._setups.append(setup) row = event.GetRow() self._updateSetupRow(row, setup) self._insertAddSetupRow(row + 1) self._onCellSelected(event)
def _onCellSelected(self, event: wx.grid.GridEvent): row = event.GetRow() col = event.GetCol() self.SelectBlock(row, col, row, col) if self._isSetupRow(row): self._owner.onSetupSelected(row) else: self._owner.onNoSetupSelected()
def _onCellDoubleLeftClick(self, event: wx.grid.GridEvent): row = event.GetRow() col = event.GetCol() if self._grid.IsReadOnly(row, col): self._grid.SelectRow(row) fitId = self._getShip(row).fitId self._onOpenFit(fitId, event.AltDown()) else: event.Skip()
def _onCellLeftClick(self, event: wx.grid.GridEvent): if self._setup is None: return row = event.GetRow() col = event.GetCol() if col == _ACTIVE_COL and self._isShipRow(row): self._getShip(row).toggleActive() self._updateShipRow(row) event.Skip()
def select_label(self, e: wx.grid.GridEvent): """ Move GridCursor to first cell of selected label rows or columns. :param e: :return: """ if e.GetCol() >= 0: self.SetGridCursor(0, e.GetCol()) elif e.GetRow() >= 0: self.SetGridCursor(e.GetRow(), 0) print(self.GetSelectionBlockTopLeft()) self.Layout() e.Skip() # do default event.
def _onCellChanging(self, event: wx.grid.GridEvent): row = event.GetRow() col = event.GetCol() if col == _SHIP_COL: if row == self._addShipRowIndex: # <Add Ship> self._onAddShip(event) elif self._isShipRow(row): self._onShipChanging(event) elif col == _FIT_COL: self._onChoosingFit(event) elif col == _ACTIVE_COL: self._getShip(row).toggleActive() self._updateShipRow(row)
def _onShipChanging(self, event: wx.grid.GridEvent): shipName = event.GetString() sMarket = Market.getInstance() newShip = sMarket.getShipByName(shipName) if newShip is None: event.Veto() return row = event.GetRow() ship = self._getShip(row) ship.shipId = newShip.typeID ship.fitId = None self._updateShipRow(row) self._grid.AutoSizeColumn(_SHIP_COL)
def _showContextMenu(self, event: wx.grid.GridEvent): row = event.GetRow() if not self._isShipRow(row): return self._grid.SelectRow(row) fitId = self._getShip(row).fitId if not hasattr(self, "openFitId"): self.openFitId = wx.NewId() self.openFitInNewTabId = wx.NewId() self.deleteFitId = wx.NewId() menu = wx.Menu() openFitItem: wx.MenuItem = menu.Append(self.openFitId, "Open Fit") self.Bind(wx.EVT_MENU, lambda _: self._onOpenFit(fitId, False), openFitItem) openFitInNewTabItem: wx.MenuItem = menu.Append(self.openFitInNewTabId, "Open Fit In New Tab") self.Bind(wx.EVT_MENU, lambda _: self._onOpenFit(fitId, True), openFitInNewTabItem) removeFromSetupItem: wx.MenuItem = menu.Append(self.deleteFitId, "Remove From Setup") self.Bind(wx.EVT_MENU, lambda _: self._onRemoveFitFromSetup(fitId), removeFromSetupItem) self.PopupMenu(menu) menu.Destroy()
def _onChoosingFit(self, event: wx.grid.GridEvent): name = event.GetString() fit = Fit.getInstance().getFitByName(name) if fit is None: event.Veto() return fitId, shipId = fit[0], fit[2] ship = self._getShip(event.GetRow()) if ship.shipId != shipId: event.Veto() return ship.fitId = fitId self._updateShipRow(event.GetRow()) self._grid.AutoSizeColumn(_SHIP_COL)
def _onAddShip(self, event: wx.grid.GridEvent): shipName = event.GetString() sMarket = Market.getInstance() newShip = sMarket.getShipByName(shipName) if newShip is None: event.Veto() return ship = SetupShip(newShip.typeID) self._setup.ships.append(ship) self._updateShipRow(event.GetRow()) self._insertAddShipRow() self._grid.AutoSizeColumn(_SHIP_COL) pass
def cell_changed(self, event: wx.grid.GridEvent): try: self.matrix.set(self.matrix.items[event.GetRow()], self.matrix.items[event.GetCol()], self.GetCellValue(event.GetRow(), event.GetCol())) self.update() self.focus_gain(None) self.GetGrandParent().GetParent().GetParent().proj_saved = False except Exception as e: self.SetCellValue(event.GetRow(), event.GetCol(), event.GetString())
def _showContextMenu(self, event: wx.grid.GridEvent): row = event.GetRow() if not self._isSetupRow(row): return if not row in self.SelectedRows: self.SelectRow(row) if not hasattr(self, "removeSetupId"): self.removeSetupId = wx.NewId() menu = wx.Menu() removeSetupItem: wx.MenuItem = menu.Append(self.removeSetupId, "Remove Setup(s)") self.Bind(wx.EVT_MENU, lambda _: self._onRemoveSetups(self.SelectedRows), removeSetupItem) self.PopupMenu(menu) menu.Destroy()
def _onRenameSetup(self, event: wx.grid.GridEvent): row = event.GetRow() setup = self._setups[event.GetRow()] setup.name = event.GetString() self._updateSetupRow(row, setup)
def _onCellChanging(self, event: wx.grid.GridEvent): row = event.GetRow() if self._isSetupRow(row): self._onRenameSetup(event) else: self._onAddSetup(event)
def on_grid_left_dclick(self, event: wx.grid.GridEvent): event_obj = event.GetEventObject() if event_obj == self.in_grid: med_id = self.in_grid.current_id self.out_grid.add(med_id) event.Skip()