Esempio n. 1
0
def setup_grid(grid, title):
    """
    This function only works with type wx.grid.Grid
    The it will create a grid that is like the one found in LinkCtrl/View.
    :param grid:
    :return:
    """

    grid.CreateGrid(6, 2)
    grid.EnableEditing(False)
    grid.EnableGridLines(True)
    grid.SetGridLineColour(wx.Colour(0, 0, 0))
    grid.EnableDragGridSize(False)

    # Columns
    grid.EnableDragColMove(False)
    grid.EnableDragColSize(True)
    grid.SetColLabelSize(0)
    grid.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
    grid.SetColSize(0, 110)

    # Rows
    grid.EnableDragRowSize(True)
    grid.SetRowLabelSize(0)
    grid.SetRowLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

    # Defaults
    grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))  # white
    grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

    # Set Cell Values
    grid.SetCellValue(0, 0, " %s" % title)
    grid.SetCellValue(1, 0, " Variable Name")
    grid.SetCellValue(2, 0, " Geometry Type")
    grid.SetCellValue(3, 0, " Geometry Count")
    grid.SetCellValue(4, 0, " Coordinate System")
    grid.SetCellValue(5, 0, " Spatial Extent")

    # set the default background color
    grid.SetDefaultCellBackgroundColour('WHITE')

    # change color and size of header
    grid.SetCellSize(0, 0, 1, 2)  # span cols 0 and 1
    grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))  # Grey

    # set the table column size
    grid.SetColSize(0, 133)
    grid.SetColSize(1, 155)

    # change color of properties
    for i in range(1, grid.GetNumberRows()):
        grid.SetCellBackgroundColour(i, 0, wx.Colour(250, 250,
                                                     250))  # light Grey

    grid.SetGridLineColour(wx.Colour(195, 195, 195))
Esempio n. 2
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       title="Grid demo",
                       pos=wx.DefaultPosition,
                       size=wx.DefaultSize,
                       style=wx.DEFAULT_FRAME_STYLE)
     sizer = wx.BoxSizer()
     self.SetSizer(sizer)
     bmp_rabbit, bmp_carrot = [
         wx.BitmapFromImage(wx.ImageFromStream(StringIO.StringIO(x)))
         for x in (IMG_RABBIT, IMG_CARROT)
     ]
     d = {"rabbit": bmp_rabbit, "carrot": bmp_carrot}
     grid = wx.grid.Grid(self)
     sizer.Add(grid, 1, wx.EXPAND)
     grid.CreateGrid(4, 5)
     grid.SetGridLineColour(wx.BLACK)
     self.grid = grid
     for i in range(4):
         hook_grid_button_column(grid, i, d)
         for j in range(4):
             grid.SetCellValue(
                 i, j, (((i + j) % 2 == 0 and "rabbit:") or "carrot:") +
                 BU_NORMAL)
         grid.SetCellValue(i, 4, "Row %d" % (i + 1))
         grid.SetReadOnly(i, 4)
     grid.SetColLabelSize(0)
     grid.SetRowLabelSize(0)
     self.Bind(EVT_GRID_BUTTON, self.on_grid_button, grid)
     self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.on_left_click,
               grid)
Esempio n. 3
0
def set_grid_line_colour(grid):
    """
   Sets a colour of (130,130,254) for the grid lines for the specified grid in case
   the wx-Version is 2.5 or greater.

   :param grid:
   """
    if wx.VERSION >= (2, 5):
        grid.SetGridLineColour(wx.Colour(130, 130, 254))
Esempio n. 4
0
    def init_grid(self, grid):
        # Grid
        grid.CreateGrid(7, 2)
        grid.EnableEditing(False)
        grid.EnableGridLines(True)
        grid.SetGridLineColour(wx.Colour(0, 0, 0))
        grid.EnableDragGridSize(False)
        grid.SetMargins(0, 0)

        # Columns
        grid.EnableDragColMove(False)
        grid.EnableDragColSize(True)
        grid.SetColLabelSize(0)
        grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Rows
        grid.EnableDragRowSize(True)
        grid.SetRowLabelSize(0)
        grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))
        grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

        # Set Cell Values
        grid.SetCellValue(0, 0, " Variable")
        grid.SetCellValue(1, 0, " Name")
        grid.SetCellValue(2, 0, " Description")
        grid.SetCellValue(3, 0, " Unit")
        grid.SetCellValue(4, 0, " Name")
        grid.SetCellValue(5, 0, " Type")
        grid.SetCellValue(6, 0, " Abbreviation")

        grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(0, 1, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 1, wx.Colour(195, 195, 195))
        grid.SetGridLineColour(wx.Colour(195, 195, 195))
        self.resize_grid_to_fill_white_space(grid)
Esempio n. 5
0
    def __init__(self, student):

        wx.Frame.__init__(self,
                          parent=None,
                          title="学生信息单",
                          pos=(100, 100),
                          size=(500, 500))

        self.panel = wx.Panel(self)
        studentMessage = student.getStudentMessage()

        wx.StaticText(self.panel, -1, studentMessage[0], pos=(50, 10))
        wx.StaticText(self.panel, -1, studentMessage[1], pos=(100, 10))

        gradeLabel = wx.StaticText(self.panel, -1, "学生成绩单", pos=(200, 10))
        gradeLabel.SetFont(wx.Font(18, wx.ROMAN, wx.ITALIC, wx.NORMAL))

        wx.StaticText(self.panel,
                      -1,
                      "================================================",
                      pos=(50, 30))
        t = str(time.localtime(time.time()).tm_year)+\
            '.'+str(time.localtime(time.time()).tm_mon)+\
            '.'+str(time.localtime(time.time()).tm_mday)

        self.gradeLabel = wx.StaticText(self.panel, -1, t, pos=(400, 10))
        grid = wx.grid.Grid(self.panel, id=-1, pos=(50, 50), size=(400, 200))

        grid.CreateGrid(10, 5)
        grid.HideRowLabels()
        grid.HideColLabels()
        grid.SetColSize(0, 69)
        grid.SetColSize(1, 100)
        grid.SetColSize(2, 69)
        grid.SetGridLineColour(wx.Colour(230, 230, 230))
        grid.SetDefaultCellBackgroundColour(wx.Colour(230, 230, 230))
        grid.EnableEditing(False)
        classesGrade = student.getCompleteStudentGrade()
        grid.SetCellValue(0, 0, '课程号')
        grid.SetCellValue(0, 1, '课程名')
        grid.SetCellValue(0, 2, '成绩')
        grid.SetCellValue(0, 3, '学分')
        grid.SetCellValue(0, 4, '教师')
        avgGrade = 0
        for i in range(len(classesGrade)):
            for j in range(len(classesGrade[i])):
                grid.SetCellValue(i + 1, j, classesGrade[i][j])
            avgGrade += int(classesGrade[i][2])
        avgLabel = wx.StaticText(self.panel,
                                 -1,
                                 "平均成绩:" + str(avgGrade / len(classesGrade)),
                                 pos=(200, 300))
        avgLabel.SetFont(wx.Font(30, wx.ROMAN, wx.ITALIC, wx.NORMAL))