def Draw(self, grid, dc, rect, row): dc.SetBrush(wx.Brush(self._bgcolor)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangle(rect) hAlign, vAlign = grid.GetRowLabelAlignment() text = grid.GetRowLabelValue(row) self.DrawBorder(grid, dc, rect) self.DrawText(grid, dc, rect, text, hAlign, vAlign)
def Draw(self, grid, dc, rect, row): #dc.SetBrush(wx.Brush(self._bgcolor)) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.Pen('blue', 5, wx.SHORT_DASH)) #dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(rect) hAlign, vAlign = grid.GetRowLabelAlignment() text = grid.GetRowLabelValue(row) self.DrawBorder(grid, dc, rect) self.DrawText(grid, dc, rect, text, hAlign, vAlign)
def __init__(self, parent, grid, format=[], total_col=None, total_row=None, rowLabels=True, colLabels=True): if total_row is None: total_row = grid.GetNumberRows() if total_col is None: total_col = grid.GetNumberCols() self.total_row = total_row self.total_col = total_col self.grid = grid self.rowLabels = rowLabels self.colLabels = colLabels data = [] for row in range(total_row): row_val = [] if rowLabels: row_val.append(grid.GetRowLabelValue(row)) for col in range(total_col): try: row_val.append(grid.GetCellValueAsString(row, col)) except: row_val.append(grid.GetCellValue(row, col)) data.append(row_val) if colLabels: label = [""] if rowLabels else [] for col in range(total_col): value = grid.GetColLabelValue(col) label.append(value) d = float(grid.GetColSize(0)) if format == []: if rowLabels: format.append(grid.GetRowLabelSize()) for col in range(total_col): col_size = grid.GetColSize(col) #print("Column size:", col,'\t',col_size) format.append(col_size) self.table = PrintTable(parent, rowLabels, colLabels) if colLabels: self.table.label = label self.table.cell_left_margin = 0.0 self.table.cell_right_margin = 0.0 self.table.set_column = format self.table.data = data
def Draw(self, grid, dc, rect, row): rect.y -= 1 if row == grid.actions.cursor[0]: color = get_color(config["selection_color"]) else: color = get_color(config["label_color"]) dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(color)) dc.DrawRectangleRect(rect) hAlign, vAlign = grid.GetRowLabelAlignment() text = grid.GetRowLabelValue(row) if row != grid.actions.cursor[0]: self.DrawBorder(grid, dc, rect) self.DrawText(grid, dc, rect, text, hAlign, vAlign)
def OnGridCameraConfMotion(self, evt): # evt.GetRow() and evt.GetCol() would be nice to have here, # but as this is a mouse event, not a grid event, they are not # available and we need to compute them by hand. grid = self.gridCameraConf x, y = grid.CalcUnscrolledPosition(evt.GetPosition()) row = grid.YToRow(y) col = grid.XToCol(x) if (row, col) != self.prev_rowcol and row >= 0 and col >= 0: self.prev_rowcol[:] = [row, col] hinttext = self.camProps[grid.GetRowLabelValue(row)][col + 2] if hinttext is None: hinttext = '' grid.GetGridWindow().SetToolTipString(hinttext) evt.Skip()
def Draw(self, grid, dc, rect, row): if row == grid.actions.cursor[0]: rect.y += 1 rect.height -= 1 pen_color = get_color(wx.SYS_COLOUR_MENUHILIGHT) pen = wx.Pen(pen_color, 2, wx.SOLID) dc.SetPen(pen) else: dc.SetPen(wx.TRANSPARENT_PEN) color = get_color(wx.SYS_COLOUR_BACKGROUND) dc.SetBrush(wx.Brush(color)) dc.DrawRectangleRect(rect) hAlign, vAlign = grid.GetRowLabelAlignment() text = grid.GetRowLabelValue(row) self.DrawBorder(grid, dc, rect) self.DrawText(grid, dc, rect, text, hAlign, vAlign)
def Draw(self, grid, dc, rect, row): graphicUtils.DrawLineGradient(dc, rect.GetX(), rect.GetY(), rect.GetX() + rect.GetWidth() - 2, rect.GetY() + rect.GetHeight() - 1, self._start_color, self._end_color) r = wx.Rect(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()) if self._drawNumRow: hAlign, vAlign = grid.GetRowLabelAlignment() text = grid.GetRowLabelValue(row) dc.SetPen(wx.TRANSPARENT_PEN) self.DrawText(grid, dc, rect, text, hAlign, vAlign) # Top Line dc.SetPen(self._top_pen) dc.DrawLine(r.GetX(), r.GetY(), r.GetX() + r.GetWidth(), r.GetY()) dc.DrawLine(r.GetX(), r.GetY() + 1, r.GetX() + r.GetWidth(), r.GetY() + 1) # Right Line dc.SetPen(self._right_pen) dc.DrawLine(r.GetX() + r.GetWidth() - 1, r.GetY(), r.GetX() + r.GetWidth() - 1, r.GetY() + r.GetHeight()) # Left Line dc.SetPen(self._left_pen) dc.DrawLine(r.GetX(), r.GetY(), r.GetX(), r.GetY() + r.GetHeight()) # Bottom dc.SetPen(self._bot_pen) dc.DrawLine(r.GetX(), r.GetY() + r.GetHeight() - 1, r.GetX() + r.GetWidth(), r.GetY() + r.GetHeight() - 1) if self.IsDrawCursor() and grid.GetGridCursorRow() == row: st = 0 sty = r.GetY() penBound = wx.Pen(SORT_BORDER_CLR) dc.SetPen(penBound) brush = wx.Brush(SORT_P_CLR, wx.SOLID) dc.SetBrush(brush) dc.DrawPolygon(CursorMarkDark, mark_shith_x + st, mark_shith_y + sty)
def __init__(self, parent, input_para): rect_parent = parent.GetRect() print rect_parent pos_target = rect_parent.GetTopRight() wx.Frame.__init__(self, parent, -1, "Resource Grid", pos=pos_target, size=(1000, 700)) panel = wx.Panel(self, -1) sizer_grid = wx.GridBagSizer(0, 0) usr_style = wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL grid = wx.grid.Grid(self, -1) grid.CreateGrid(12 * 2, 14) cell_width = 20 grid.DisableDragColSize() grid.DisableDragGridSize() grid.DisableDragRowSize() grid.SetRowLabelAlignment(wx.CENTER, wx.CENTER) clo_num = grid.GetNumberCols() row_num = grid.GetNumberRows() for i in range(0, row_num): grid.SetRowLabelValue(i, str(row_num - i - 1)) grid.AutoSizeRowLabelSize(i) grid.SetRowLabelSize(cell_width) grid.SetDefaultRowSize(cell_width) for j in range(0, clo_num): grid.SetColLabelValue(j, str(j)) grid.AutoSizeColLabelSize(j) grid.SetRowLabelSize(cell_width) grid.SetDefaultColSize(cell_width) grid.SetDefaultCellBackgroundColour(wx.Colour(192, 192, 192)) #pdcch for i in range(0, row_num): for j in range(0, clo_num): grid.SetReadOnly(i, j) if (j < input_para['pdcch_symbol']): grid.SetCellBackgroundColour(i, j, wx.GREEN) if ((int(grid.GetRowLabelValue(i)) - 1) % 4 == 0): grid.SetCellBackgroundColour(i, j, wx.Colour(66, 66, 111)) #pdsch for i in range(0, row_num): for j in range(input_para['start_symbol'], clo_num): if (j - input_para['start_symbol'] < input_para['symbol_length']): grid.SetCellBackgroundColour(i, j, wx.Colour(255, 255, 255)) #pdsch dmrs for j in range(0, len(input_para['dmrs_pos_list'])): for i in range(0, row_num): if input_para['dmrs_length'] == 0 and j == 0: grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(153, 204, 50)) continue if input_para['dmrs_length'] == 1 and (j == 1 or j == 0): grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(153, 204, 50)) continue else: grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(234, 234, 173)) sizer_grid.Add(grid, pos=(0, 0), span=(5, 5), flag=wx.EXPAND | usr_style) lbl_pdcch = wx.StaticText(self, -1, u' PDCCH ', style=usr_style) lbl_pdcch.SetBackgroundColour(wx.GREEN) sizer_grid.Add(lbl_pdcch, pos=(7, 0), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_pdcch_dmrs = wx.StaticText( self, -1, u' PDCCH DMRS ', style=usr_style, ) lbl_pdcch_dmrs.SetBackgroundColour(wx.Colour(66, 66, 111)) lbl_pdcch_dmrs.SetForegroundColour(wx.Colour(255, 255, 255)) sizer_grid.Add( lbl_pdcch_dmrs, pos=(7, 1), span=(1, 1), flag=wx.EXPAND | usr_style, ) lbl_pdsch = wx.StaticText(self, -1, u' PDXCH ', style=usr_style) lbl_pdsch.SetBackgroundColour(wx.Colour(255, 255, 255)) lbl_pdsch.SetForegroundColour(wx.Colour(0, 0, 0)) sizer_grid.Add(lbl_pdsch, pos=(7, 2), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_fl_dmrs = wx.StaticText(self, -1, u'Front Loaded DMRS', style=usr_style) lbl_fl_dmrs.SetBackgroundColour(wx.Colour(153, 204, 50)) lbl_fl_dmrs.SetForegroundColour(wx.Colour(255, 255, 255)) sizer_grid.Add(lbl_fl_dmrs, pos=(8, 0), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_add_dmrs = wx.StaticText(self, -1, u'Add DMRS', style=usr_style) lbl_add_dmrs.SetBackgroundColour(wx.Colour(234, 234, 173)) lbl_add_dmrs.SetForegroundColour(wx.Colour(0, 0, 0)) sizer_grid.Add(lbl_add_dmrs, pos=(8, 1), span=(1, 1), flag=wx.EXPAND | usr_style) b_close = wx.Button(self, -1, "Close") self.Bind(wx.EVT_BUTTON, self.close_window, b_close) sizer_grid.Add(b_close, pos=(10, 0), span=(2, 5), flag=wx.EXPAND | usr_style) self.equal = b_close self.SetSizer(sizer_grid) sizer_grid.Fit(self) self.Show()