Example #1
0
 def Draw(self, grid, dc, rect, col):
     dc.SetBrush(wx.Brush(self._bgcolor))
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.DrawRectangle(rect)
     hAlign, vAlign = grid.GetColLabelAlignment()
     text = grid.GetColLabelValue(col)
     self.DrawBorder(grid, dc, rect)
     self.DrawText(grid, dc, rect, text, hAlign, vAlign)
Example #2
0
 def Draw(self, grid, dc, rect, col):
     dc.SetBrush(wx.Brush(self._bgcolor))
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.DrawRectangleRect(rect)
     hAlign, vAlign = grid.GetColLabelAlignment()
     text = grid.GetColLabelValue(col)
     self.DrawBorder(grid, dc, rect)
     dc.Font.Weight = wx.BOLD
     # dc.Font.PointSize = 18
     self.DrawText(grid, dc, rect, text, hAlign, vAlign)
Example #3
0
    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
Example #4
0
    def on_saveButton(self, event, grid):
        """saves any editing of the grid but does not continue to the next window"""
        wait = wx.BusyInfo("Please wait, working...")
        wx.SafeYield()

        if self.grid_frame.drop_down_menu:  # unhighlight selected columns, etc.
            self.grid_frame.drop_down_menu.clean_up()

        # remove '**' and '^^' from col labels
        starred_cols, hatted_cols = grid.remove_starred_labels()

        grid.SaveEditControlValue() # locks in value in cell currently edited
        grid.HideCellEditControl() # removes focus from cell that was being edited

        if grid.changes:
            self.onSave(grid)

        for col in starred_cols:
            label = grid.GetColLabelValue(col)
            grid.SetColLabelValue(col, label + '**')
        for col in hatted_cols:
            label = grid.GetColLabelValue(col)
            grid.SetColLabelValue(col, label + '^^')
        del wait
Example #5
0
    def Draw(self, grid, dc, rect, col):
        rect.x -= 1
        if col == grid.actions.cursor[1]:
            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.GetColLabelAlignment()
        text = grid.GetColLabelValue(col)
        if col != grid.actions.cursor[1]:
            self.DrawBorder(grid, dc, rect)
        self.DrawText(grid, dc, rect, text, hAlign, vAlign)
Example #6
0
 def _get_grid(self, grid):
     """
     given a wxpython Grid objcect, gather all the data, write it out to the ApplicationData objcet and return it.
     """
     data = []
     num_rows = grid.GetNumberRows()
     num_columns = grid.GetNumberCols()
     for row_num in xrange(0, num_rows):
         row = {}
         for column_num in xrange(0, num_columns):
             field_name = grid.GetColLabelValue(column_num)
             value = grid.GetCellValue(row_num, column_num)
             row[field_name] = value
         data.append(row)
     self.application_data.write(mounts=data)
     return data
Example #7
0
    def Draw(self, grid, dc, rect, col):
        if col == grid.actions.cursor[1]:
            rect.x += 1
            rect.width -= 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.GetColLabelAlignment()
        text = grid.GetColLabelValue(col)
        self.DrawBorder(grid, dc, rect)
        self.DrawText(grid, dc, rect, text, hAlign, vAlign)
Example #8
0
 def Draw(self,grid, dc, rect, col):
     text = grid.GetColLabelValue(col).title()
     self.do_draw(grid, dc, rect, text, grid.GetSortingColumn() == col)
Example #9
0
    def Draw(self, grid, dc, rect, col):
        graphicUtils.DrawLineGradient(dc, rect.GetX(), rect.GetY(),
                                      rect.GetX() + rect.GetWidth() - 2,
                                      rect.GetY() + rect.GetHeight(),
                                      self._start_color, self._end_color)
        r = wx.Rect(rect.GetX(), rect.GetY(), rect.GetWidth(),
                    rect.GetHeight())
        hAlign, vAlign = grid.GetColLabelAlignment()
        text = grid.GetColLabelValue(col)

        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() - 2, r.GetY(),
                    r.GetX() + r.GetWidth() - 2,
                    r.GetY() + r.GetHeight())
        # Left Line
        dc.SetPen(self._left_pen)
        dc.DrawLine(r.GetX(), r.GetY(), r.GetX(), r.GetY() + r.GetHeight())
        dc.DrawLine(r.GetX() + r.GetWidth() - 1, r.GetY(),
                    r.GetX() + r.GetWidth() - 1,
                    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.CanSort() and r.GetWidth() > 5:
            penBound = wx.Pen(SORT_BORDER_CLR)
            dc.SetPen(penBound)
            clr = BOT_LAB_CLR
            stx = r.GetX()
            st = 0
            # Колока не сортирована
            if self.sortDirection == 0:
                brush = wx.Brush(SORT_UP_CLR, wx.SOLID)
                dc.SetBrush(brush)
                dc.DrawPolygon(SortMarkPointsDark, mark_shith_x + stx,
                               mark_shith_y + st)
            # Колонка отсортирована по убыванию
            elif self.sortDirection < 0:
                brush = wx.Brush(SORT_P_CLR, wx.SOLID)
                dc.SetBrush(brush)
                dc.DrawPolygon(SortMarkPointsDark, mark_shith_x + stx,
                               mark_shith_y + st)
            # Колонка отсортирована по возрастанию
            else:
                brush = wx.Brush(SORT_P_CLR, wx.SOLID)
                dc.SetBrush(brush)
                dc.DrawPolygon(SortMarkPointsDarkUp, mark_shith_x + stx,
                               mark_shith_y + st)