Exemple #1
0
    def __init__(self, parent, vlist=[], ntitle="Values"):
        wx.Frame.__init__(self, parent, -1, ntitle, wx.DefaultPosition,
                          wx.Size(400, 500))
        global dir_path
        self.SetMenu()
        icon_path = os.path.join(dir_path, "Icon")

        self.icon = wx.Icon(os.path.join(icon_path, "Text.ico"),
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        wx.BeginBusyCursor()
        self.grid = grid = wx.Grid(self, -1)

        rtotal = len(vlist)
        try:
            ctotal = len(vlist[0])
        except:
            ctotal = 1

        grid.CreateGrid(rtotal, ctotal)

        grid.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)

        row = 0
        for val in vlist:
            col = 0
            for set in val:
                grid.SetCellValue(row, col, str(set))
                col += 1
            row += 1

        grid.AutoSizeRows()
        grid.Refresh()
        wx.EndBusyCursor()
Exemple #2
0
    def __init__(self, parent):
        global LR0TABLE

        wx.Frame.__init__(self, parent)

        # Create a wxGrid object
        grid = wx.grid.Grid(self, -1)

        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.CreateGrid(len(LR0TABLE) + 5, len(VtVn) + 5)

        # We can set the sizes of individual rows and columns
        # in pixels

        grid.SetCellValue(0, 0, '状态')
        grid.SetCellValue(0, 1, '-')
        grid.SetCellValue(0, 2, 'ACTION')
        grid.SetCellValue(0, 3, '-')
        grid.SetCellValue(0, 4, '-')
        grid.SetCellValue(0, 5, '-')
        grid.SetCellValue(0, 6, 'GOTO')
        grid.SetCellValue(0, 7, '-')
        grid.SetCellValue(0, 8, '-')

        for i in range(len(LR0TABLE)):
            grid.SetCellValue(i + 2, 0, str(i))
            for j in range(len(LR0TABLE[i])):
                grid.SetCellValue(i + 1, j + 1, LR0TABLE[i][j])

        self.Show()
Exemple #3
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)
Exemple #4
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)
Exemple #5
0
    def OnOpenLogcatClicked(self, event):
        self.loadDataBase(2)
        self.SetSize(980, 560)
        grid = wx.grid.Grid(self, pos=(320, 0), size=(640, 500))
        grid.CreateGrid(100, 4)
        for i in range(100):
            for j in range(4):
                grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetColLabelValue(0, "工号")  #第一列标签
        grid.SetColLabelValue(1, "姓名")
        grid.SetColLabelValue(2, "打卡时间")
        grid.SetColLabelValue(3, "是否迟到")

        grid.SetColSize(0, 120)
        grid.SetColSize(1, 120)
        grid.SetColSize(2, 150)
        grid.SetColSize(3, 150)

        grid.SetCellTextColour("NAVY")
        for i, id in enumerate(self.logcat_id):
            grid.SetCellValue(i, 0, str(id))
            grid.SetCellValue(i, 1, self.logcat_name[i])
            grid.SetCellValue(i, 2, self.logcat_datetime[i])
            grid.SetCellValue(i, 3, self.logcat_late[i])

        pass
Exemple #6
0
        def __init__(self, parent):
            wx.Frame.__init__(self, parent)



            # create a wxGrid object
            grid = wx.grid.Grid(self, -1)
            grid.CreateGrid(100, 10)

            #setting sizes of individual rows and colums in pixels
            grid.SetRowSize(0, 60)
            grid.SetColSize(0, 120)

            #set grid contents as strings
            grid.SetCellValue(0,0,'wxgrid is good')

            #can specify cells as read-only
            grid.SetReadOnly(0,0)

            #colors for cell contents
            grid.SetCellValue(0,1,'color!')
            grid.SetCellTextColour(0,1,wx.LIGHT_GREY)

            #define the default cell text color
            grid.SetDefaultCellTextColour(wx.BLACK)

            self.Show()
Exemple #7
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='Statistics')

        wtl = CsvTimeLogger()
        statistics = wtl.get_statistics()
        panel = wx.Panel(self)
        top_sizer = wx.BoxSizer(wx.VERTICAL)

        grid = wx.grid.Grid(self, -1)
        grid.CreateGrid(len(statistics), 2)  # + 1 due to summary row at end
        grid.SetColLabelValue(0, "Day")
        grid.SetColLabelValue(1, "Worked")
        grid.SetRowLabelSize(0)

        for i, (k, v) in enumerate(statistics.items()):
            grid.SetCellValue(i, 1, format_timedelta(v))
            grid.SetCellAlignment(i, 1, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
            if isinstance(k, dt.date):
                grid.SetCellValue(i, 0, k.strftime('%a %Y-%m-%d'))
                grid.SetCellAlignment(i, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)

                rel_extra_time = v.total_seconds() / dt.timedelta(hours=4).seconds
                grid.SetCellBackgroundColour(i, 1, get_color_red_white_blue(rel_extra_time))
            else:
                grid.SetCellValue(i, 0, k)

        grid.AutoSize()
        top_sizer.Add(grid, 0, wx.CENTER)
        panel.SetSizer(top_sizer)
        top_sizer.Fit(self)
        self.Show()
Exemple #8
0
    def __init__(self):
        wx.Frame.__init__(self, None, title="Grid Headers", size=(500, 200))
        grid = wx.grid.Grid(self)
        grid.CreateGrid(5, 5)
        for row in range(5):
            #1 start
            grid.SetColLabelValue(row, self.colLabels[row])
            #1 end
        grid.AppendRows()

        # panel=wx.Panel(self)
        # panel.SetBackgroundColour('White')
        # statusbar=self.CreateStatusBar()
        # # toolbar=self.CreateToolBar()
        # # toolbar.AddSimpleTool(wx.NewId(),images.getPyBitmap(),
        # #       "New","Long help for 'New'")
        # # toolbar.Realize()
        # menuBar = wx.MenuBar()
        # menu1=wx.Menu()
        # menu1.Append(wx.NewId(),u"新字幕",u"新建一个字幕")
        # menu1.Append(wx.NewId(),u"打开字幕",u"打开一个字幕")
        # menu1.Append(wx.NewId(),u"保存字幕",u"保存一个字幕")
        # menuBar.Append(menu1,u"文件")
        # menu2=wx.Menu()
        # menu2.Append(wx.NewId(),u"撤销","Copy in status bar")
        # menu2.Append(wx.NewId(),u"复制","ctrl+c")
        # menu2.Append(wx.NewId(),u"粘贴","ctrl+v")
        # menu2.AppendSeparator()
        # menu2.Append(wx.NewId(),u"显示选项","Display Options")
        # menuBar.Append(menu2, u"编辑")
        # self.SetMenuBar(menuBar)
        # # print wx.grid.Grid.__doc__
        # grid = wx.grid.Grid(self)
        # box = wx.BoxSizer(wx.HORIZONTAL)
        # box.Add(grid,0,wx.EXPAND)

        # grid.CreateGrid(5,5)
        # # print grid.CreateGrid.__doc__
        # for row in range(5):
        #     for col in range(5):
        #         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)


# app = wx.PySimpleApp()
# frame = TestFrame()
# frame.Show()
# app.MainLoop()
Exemple #9
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        # Create a wxGrid object
        grid = wx.grid.Grid(self, -1)

        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.CreateGrid(100, 10)

        # We can set the sizes of individual rows and columns
        # in pixels

        grid.SetColSize(5, 200)
        # And set grid cell contents as strings
        grid.SetCellValue(0, 0, 'wxGrid is good')

        # We can specify that some cells are read.only
        grid.SetCellValue(0, 3, 'This is read.only')
        grid.SetReadOnly(0, 3)

        # Colours can be specified for grid cell contents
        grid.SetCellValue(3, 3, 'green on grey')
        grid.SetCellTextColour(3, 3, wx.GREEN)
        grid.SetCellBackgroundColour(3, 3, wx.LIGHT_GREY)

        # We can specify the some cells will store numeric
        # values rather than strings. Here we set grid column 5
        # to hold floating point values displayed with width of 6
        # and precision of 2
        grid.SetColFormatFloat(5, 6, 2)
        grid.SetCellValue(0, 6, '3.1415')

        self.Show()
 def setupGrid(self, grid, states, stateTypes):
     nStates = len(states)
     
     grid.SetDefaultColSize(70)
     grid.CreateGrid(nStates, nStates)
     
     for i in range(nStates):
         grid.SetRowLabelValue(i, states[i])
         grid.SetColLabelValue(i, states[i])
         grid.SetReadOnly(i, i)
         grid.SetCellBackgroundColour(i, i, wx.LIGHT_GREY)
         grid.SetCellTextColour(i, i, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.TO_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(i, j)
                 grid.SetCellBackgroundColour(i, j, wx.LIGHT_GREY)
                 grid.SetCellTextColour(i, j, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.FROM_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(j, i)
                 grid.SetCellBackgroundColour(j, i, wx.LIGHT_GREY)
                 grid.SetCellTextColour(j, i, wx.LIGHT_GREY)
                 
     grid.SetMinSize(grid.BestSize)
Exemple #11
0
 def __init__(self):
     wx.Frame.__init__(self, None, title="Simple Grid", size=(640, 480))
     grid = wx.grid.Grid(self)
     grid.CreateGrid(50, 50)
     for row in range(20):
         for col in range(6):
             grid.SetCellValue(row, col, "cell (%d,%d)" % (row, col))
Exemple #12
0
    def OnOpenRecordClicked(self, event):
        self.callDataBase(2)
        grid = wx.grid.Grid(self, pos=(320, 0), size=(600, 500))
        grid.CreateGrid(100, 4)
        for i in range(100):
            for j in range(4):
                grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetColLabelValue(0, "学号")
        grid.SetColLabelValue(1, "姓名")
        grid.SetColLabelValue(2, "签到时间")
        grid.SetColLabelValue(3, "是否迟到")

        grid.SetColSize(0, 100)
        grid.SetColSize(1, 100)
        grid.SetColSize(2, 150)
        grid.SetColSize(3, 150)

        grid.SetCellTextColour("NAVY")
        for i, id in enumerate(self.Sign_Info_id):
            grid.SetCellValue(i, 0, str(id))
            grid.SetCellValue(i, 1, self.Sign_Info_name[i])
            grid.SetCellValue(i, 2, self.Sign_Info_time_info[i])
            grid.SetCellValue(i, 3, self.Sign_Info_if_late[i])

        pass
Exemple #13
0
 def __init__(self):
     wx.Frame.__init__(self, None, title="Drop Target", size=(500, 300))
     p = wx.Panel(self)
     # create the controls
     label = wx.StaticText(p, -1, "Drop some files here:")
     text = wx.TextCtrl(p, -1, "", style=wx.TE_MULTILINE | wx.HSCROLL)
     listBox = wx.ListBox(p, -1)
     grid = wx.grid.Grid(p, -1, wx.DefaultPosition, wx.DefaultSize, 0)
     grid.CreateGrid(0, 2)
     # setup the layout with sizers
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(label, 0, wx.ALL, 5)
     sizer.Add(text, 1, wx.EXPAND | wx.ALL, 5)
     sizer.Add(listBox, 1, wx.EXPAND | wx.ALL, 5)
     sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 5)
     p.SetSizer(sizer)
     # make the text control be a drop target
     dtText = textFileDropTarget(text)  # 将文本控件作为释放到的目标
     dtText.setExts('.jpg')
     text.SetDropTarget(dtText)
     dt = listFileDropTarget(listBox)  # 将文本控件作为释放到的目标
     dt.setExts('.jpg')
     listBox.SetDropTarget(dt)
     dtGrid = gridFileDropTarget(grid)  # 将文本控件作为释放到的目标
     dtGrid.setExts('.jpg')
     grid.SetDropTarget(dtGrid)
Exemple #14
0
 def __init__(self, parent, title, size=(400, 600)):
     wx.Frame.__init__(self, parent, title=title, size=size)
     grid = wx.grid.Grid(self)
     grid.CreateGrid(50, 50)
     for row in range(20):
         for col in range(6):
             grid.SetCellValue(row, col, "Cell (%d,%d)" % (row, col))
Exemple #15
0
    def OnOpenLogcatClicked(self, event):
        if user_now == ID_WORKER_UNAVIABLE:
            wx.MessageBox(message="未检测到用户,请进行识别", caption="警告")
        else:
            self.loadDataBase(2)
            # 必须要变宽才能显示 scroll
            self.SetSize(980, 560)
            grid = wx.grid.Grid(self, pos=(320, 0), size=(640, 500))
            grid.CreateGrid(100, 4)
            for i in range(100):
                for j in range(4):
                    grid.SetCellAlignment(i, j, wx.ALIGN_CENTER,
                                          wx.ALIGN_CENTER)
            grid.SetColLabelValue(0, "序号")  # 第一列标签
            grid.SetColLabelValue(1, "姓名")
            grid.SetColLabelValue(2, "识别时间")
            grid.SetColLabelValue(3, "操作")

            grid.SetColSize(0, 120)
            grid.SetColSize(1, 120)
            grid.SetColSize(2, 150)
            grid.SetColSize(3, 150)

            grid.SetCellTextColour(1, 1, 'red')
            for i, id in enumerate(self.logcat_id):
                grid.SetCellValue(i, 0, str(id))
                grid.SetCellValue(i, 1, self.logcat_name[i])
                grid.SetCellValue(i, 2, self.logcat_datetime[i])
                grid.SetCellValue(i, 3, self.logcat_late[i])

            pass
Exemple #16
0
    def CreateGrid(self):

        grid = wx.grid.Grid(self, -1, wx.Point(0, 0), wx.Size(150, 250),
                            wx.NO_BORDER | wx.WANTS_CHARS)

        grid.CreateGrid(50, 20)

        return grid
Exemple #17
0
    def __init__(self,
                 parent,
                 id,
                 title,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 data=[],
                 head=[],
                 info=[]):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        grid = wx.grid.Grid(self, -1)

        col = len(data[0])
        row = len(data)

        colnum = len(head)
        inforownum = len(info)

        collen = []
        for c in range(colnum):
            lmax = 0
            for item in data:
                l = len(str(item[c]))
                if lmax < l:
                    lmax = l
            l = len(str(head[c]))
            if lmax < l:
                lmax = l

            collen.append(lmax)

        grid.CreateGrid(row + inforownum, col)

        grid.SetRowSize(0, 30)
        for i, value in enumerate(collen):
            grid.SetColSize(i, value * 8 + 20)

        for i, item in enumerate(head):
            grid.SetColLabelValue(i, item)

        for irow, x in enumerate(data):
            for icol, item in enumerate(x):
                grid.SetCellValue(irow + inforownum, icol, str(item))
                grid.SetReadOnly(irow + inforownum, icol)

        #设置头信息格

        headstr = ''
        for item in info:
            headstr += item

        grid.SetCellSize(0, 0, inforownum, colnum)
        grid.SetCellValue(0, 0, headstr)

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
Exemple #18
0
 def __init__(self):
     wx.Frame.__init__(self, None, title="Grid Sizes", size=(600, 300))
     grid = wx.grid.Grid(self)
     grid.CreateGrid(5, 5)
     for row in range(5):
         for col in range(5):
             grid.SetCellValue(row, col, "(%s,%s)" % (row, col))
     grid.SetCellSize(2, 2, 2, 3)
     grid.SetColSize(1, 125)
     grid.SetRowSize(1, 100)
Exemple #19
0
 def CreateGrid(self, parent):
     grid = wx.grid.Grid(parent)
     grid.CreateGrid(len(list_jsj), len(list_jsj[0]))
     for row in range(len(list_jsj)):
         for col in range(len(list_jsj[row])):
             grid.SetColLabelValue(col, column_names[col])
             grid.SetCellValue(row, col, list_jsj[row][col])
     # 设置行和列自动调整
     grid.AutoSize()
     return grid
Exemple #20
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.AutoSize()
        return grid
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, size=wx.DefaultSize)

        pnl2 = wx.lib.scrolledpanel.ScrolledPanel(self,
                                                  3,
                                                  size=(1200, 500),
                                                  pos=(10, 10),
                                                  style=wx.SIMPLE_BORDER)
        pnl2.SetupScrolling()

        self.DueDateDatabase()
        self.sendsms()
        self.birthdaysms()

        conn = sqlite3.connect('MemberData.db')
        c = conn.cursor()
        c.execute('SELECT * FROM gym3')
        data = c.fetchall()
        conn.close()

        count = 0
        for i in data:
            count += 1

        grid = wx.grid.Grid(pnl2, -1)
        grid.CreateGrid(count, 8)

        grid.SetColSize(0, 120)
        grid.SetColSize(1, 200)
        grid.SetColSize(2, 150)
        grid.SetColSize(3, 150)
        grid.SetColSize(4, 120)
        grid.SetColSize(5, 120)
        grid.SetColSize(6, 150)

        grid.SetColLabelValue(0, "Enrollment No.")
        grid.SetColLabelValue(1, "Name")
        grid.SetColLabelValue(2, "Contact No.")
        grid.SetColLabelValue(3, "Residence No.")
        grid.SetColLabelValue(4, "Date of Joining")
        grid.SetColLabelValue(5, "Fee Paid")
        grid.SetColLabelValue(6, "Membership Time")
        grid.SetColLabelValue(7, "Status")

        z = -1
        for i in data:
            z += 1
            for j in range(0, 8):
                a = str(i[j])
                grid.SetCellValue(z, j, a)
                grid.SetReadOnly(z, j)

        gbox = wx.BoxSizer()
        gbox.Add(grid, 1, wx.EXPAND)
        pnl2.SetSizer(gbox)
Exemple #22
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))
Exemple #23
0
 def __init__(self):
     wx.Frame.__init__(self, None, title="Grid Headers", size=(500, 200))
     grid = wx.grid.Grid(self)
     grid.CreateGrid(5, 5)
     for row in range(5):
         grid.SetRowLabelValue(row, self.rowLabels[row])
         grid.SetColLabelValue(row, self.colLabels[row])
         for col in range(5):
             grid.SetCellValue(
                 row, col,
                 "(%s,%s)" % (self.rowLabels[row], self.colLabels[col]))
Exemple #24
0
 def __init__(self):
     rowtitle=[u'第1行',u'第2行',u'第3行',u'第4行',]
     coltitle=[u'第1列',u'第2列',u'第3列',u'第4列',]
     wx.Frame.__init__(self,None,title=u'表格',size=(450,500))
     grid=wx.grid.Grid(self)#定义表格控件
     grid.CreateGrid(4,4)
     for i in range(4):
         grid.SetRowLabelValue(i,rowtitle[i])#行标题
         grid.SetColLabelValue(i,coltitle[i])#列标题
         for j in range(4):
             grid.SetCellValue(i,j,str(j))#设置单元格的值
Exemple #25
0
 def __init__(self):
     rowTitles = [u"第1行", u"第2行", u"第3行", u"第4行"]
     colTitles = [u"第1列", u"第2列", u"第3列", u"第4列"]
     wx.Frame.__init__(self, None, title=u"表格", size=(450, 160))
     grid = wx.grid.Grid(self)  # 定义表格控件
     grid.CreateGrid(4, 4)
     for row in range(4):
         grid.SetRowLabelValue(row, rowTitles[row])  # 设置行标题
         grid.SetColLabelValue(row, colTitles[row])  # 设置列标题
         for col in range(4):
             grid.SetCellValue(row, col, str(col))  # 设置单元格的值
Exemple #26
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       "A simple Grid Example",
                       size=(480, 600))
     grid = wx.grid.Grid(self)
     grid.CreateGrid(50, 50)
     for row in range(20):
         for col in range(50):
             grid.SetCellValue(row, col, "cell in (%d,%d)" % (row, col))
Exemple #27
0
    def CreateGrid(self, parent):
        grid = wx.grid.Grid(parent)
        grid.CreateGrid(len(data), len(data[0]))

        for row in range(len(data)):
            for col in  range(len(data[row])):
                grid.SetColLabelValue(col, column_names[col])
                grid.SetCellValue(row, col, data[row][col])

        grid.AutoSize()

        return grid
    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))
Exemple #29
0
    def __init__(self):
        wx.Frame.__init__(self, None, title="Grid Renderer", size=(640, 480))

        grid = wx.grid.Grid(self)
        grid.CreateGrid(50, 50)

        # Set this custom renderer just for row 4
        attr = wx.grid.GridCellAttr()
        attr.SetRenderer(RandomBackgroundRenderer())
        grid.SetRowAttr(4, attr)

        for row in range(10):
            for col in range(10):
                grid.SetCellValue(row, col, "cell (%d,%d)" % (row, col))
Exemple #30
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])

                # if r % 2 == 0:
                #     grid.SetCellBackgroundColour(r, c, "SEA green")
                # else:
                #     grid.SetCellBackgroundColour(r, c, "SLATE blue")
        grid.AutoSize()
        return grid