Beispiel #1
0
    def __init__(self, filename):
        wx.Frame.__init__(self, None, title="Grid Attributes", size=(600, 300))
        data = xlrd.open_workbook(filename, formatting_info=True)

        table = data.sheets()[0]

        nrow = table.nrows
        ncol = table.ncols

        grid = wx.grid.Grid(self)
        grid.CreateGrid(nrow, ncol)
        for col in range(ncol):
            for row in range(nrow):
                cell = table.cell(row, col)
                if cell.ctype == 1:
                    content = cell.value.encode("UTF-8")
                elif cell.ctype == 2:
                    content = str(cell.value)

                grid.SetCellValue(row, col, content)

        grid.SetCellTextColour(1, 1, "red")
        grid.SetCellFont(1, 1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
        grid.SetCellBackgroundColour(2, 2, "light blue")

        attr = wx.grid.GridCellAttr()
        attr.SetTextColour("navyblue")
        attr.SetBackgroundColour("pink")
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        grid.SetAttr(2, 0, attr)

        grid.SetRowAttr(0, attr)
Beispiel #2
0
 def set_scores(self, players_list, grid):  # set best scores in the right table
     counter = 0
     num = len(players_list)/2
     for i in range(int(num)):
         for j in range(2):
             grid.SetReadOnly(i, j, True)
             grid.SetCellFont(i, j, wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD))
             grid.SetCellBackgroundColour(i, j,(206, 126, 206))
             grid.SetCellValue(i, j, players_list[counter])
             counter = counter + 1
Beispiel #3
0
 def CreateGrid(self, parent):
     grid = wx.grid.Grid(parent)
     grid.CreateGrid(len(data), len(data[0]))
     for r in range(len(data)):
         for c in range(len(data[r])):
             grid.SetColLabelValue(c, column_names[c])
             grid.SetCellValue(r, c, data[r][c])
             grid.SetCellAlignment(r, c, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
             font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False)
             grid.SetCellFont(r, c, font)
             if r % 2 == 0:
                 grid.SetCellBackgroundColour(r, c, "SEA green")
             else:
                 grid.SetCellBackgroundColour(r, c, "SLATE blue")
     grid.AutoSize()
     return grid
    def update_grid(self, *args):
        """Fill the grid rows with data, and set the right editors."""
        # @type grid wx.grid.Grid
        grid = self.panel.gridExp

        #Adjust number of rows
        num_rows = len(model.instrument.inst.positions)
        if grid.GetNumberRows() > num_rows:
            grid.DeleteRows(0, grid.GetNumberRows() - num_rows)
        else:
            old_num_rows = grid.GetNumberRows()
            grid.AppendRows(num_rows - grid.GetNumberRows())
            #Set the editors for the new rows
            choices = model.experiment.get_stopping_criteria_names()
            for row in xrange(old_num_rows, num_rows):
                grid.SetCellEditor(row, self.criterion_col,
                                   wx.grid.GridCellChoiceEditor(choices))

        #Font for angles
        angle_font = wx.Font(10, 76, wx.NORMAL, wx.NORMAL, False, u'Monospace')
        for (i, poscov) in enumerate(model.instrument.inst.positions):
            row = i
            #The checkbox
            grid.SetCellAlignment(row, 0, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            grid.SetReadOnly(row, 0, True)  #Do set it read-only
            #The angles
            for (j, angleinfo) in enumerate(model.instrument.inst.angles):
                x = poscov.angles[j]
                col = j + 1
                grid.SetCellValue(row, col,
                                  u"%8.2f" % angleinfo.internal_to_friendly(x))
                grid.SetReadOnly(row, col, True)  #Do set it read-only
                grid.SetCellAlignment(row, col, wx.ALIGN_CENTRE,
                                      wx.ALIGN_CENTRE)
                grid.SetCellFont(row, col, angle_font)
            #The criterion
            grid.SetCellValue(
                row, self.criterion_col,
                model.experiment.get_stopping_criterion_friendly_name(
                    poscov.criterion))
            grid.SetCellValue(row, self.criterion_col + 1,
                              str(poscov.criterion_value))
            #Comment string
            grid.SetCellValue(row, self.criterion_col + 2, str(poscov.comment))

        self.update_selection()
Beispiel #5
0
    def __init__(self):
        wx.Frame.__init__(self, None, title="Grid Attributes", size=(600, 300))
        grid = wx.grid.Grid(self)
        grid.CreateGrid(10, 6)
        for row in range(10):
            for col in range(6):
                grid.SetCellValue(row, col, "(%s,%s)" % (row, col))

        grid.SetCellTextColour(1, 1, "red")
        grid.SetCellFont(1, 1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
        grid.SetCellBackgroundColour(2, 2, "light blue")

        attr = wx.grid.GridCellAttr()
        attr.SetTextColour("navyblue")
        attr.SetBackgroundColour("pink")
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        grid.SetAttr(4, 0, attr)
        grid.SetAttr(5, 1, attr)
        grid.SetRowAttr(8, attr)
Beispiel #6
0
 def CreateGrid(self, parent):
     # pp = wx.Panel(parent)
     # grid = wx.grid.Grid(pp)
     grid = wx.grid.Grid(parent)
     grid.CreateGrid(len(data), len(data[0]))
     grid.SetColSize(0, 70)
     grid.SetColSize(1, 110)
     grid.SetColSize(2, 70)
     grid.SetColSize(3, 110)
     grid.SetColSize(4, 110)
     grid.SetColSize(5, 110)
     grid.SetColMinimalAcceptableWidth(80)
     grid.SetRowMinimalAcceptableHeight(50)
     for r in range(len(data)):
         grid.SetRowSize(r, 50)
         for c in range(len(data[r])):
             # grid.SetColLabelValue(c, column_names[c])
             grid.SetCellValue(r, c, str(data[r][c]))
             grid.SetCellAlignment(r, c, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
             font = wx.Font(15, wx.SWISS, wx.NORMAL, wx.BOLD, False)
             grid.SetCellFont(r, c, font)
     grid.AutoSize()
     # pp.SetSizer(grid)
     return grid