Beispiel #1
0
    def on_btn_refresh_click(self, event):
        data = utils.load_file()[-10:]
        # Create a wxGrid object
        fm = wx.Frame(self, -1, title='Log Info', size=(500, 300))

        grid = wx.grid.Grid(fm, -1)

        grid.CreateGrid(len(data), 4)
        grid.SetColLabelValue(0, 'ID')
        grid.SetColLabelValue(1, 'Data')
        grid.SetColLabelValue(2, 'Nome')
        grid.SetColLabelValue(3, 'Mensagem')

        for row, x in enumerate(data):
            for col, value in enumerate(x):
                grid.SetCellValue(row, col, str(value))
        grid.AutoSize()
        grid.AutoSizeColumn(3)
        fm.Centre()
        fm.Show()
Beispiel #2
0
    def _updateColAttrs(self, grid):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """
        
        for col in range(self.GetNumberCols()):
            attr = wx.grid.GridCellAttr()
            attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE)
            grid.SetColAttr(col, attr)
            grid.SetColMinimalWidth(col, ColSizes[col])
            grid.AutoSizeColumn(col, False)
        
        typelist = None
        maplist = None
        for row in range(self.GetNumberRows()):
            editors = self.editors[row]
            if wx.Platform == '__WXMSW__':
                grid.SetRowMinimalHeight(row, 20)
            else:
                grid.SetRowMinimalHeight(row, 28)
            grid.AutoSizeRow(row, False)
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                
                colname = self.GetColLabelValue(col, False)
                editortype = editors[colname]
                if editortype == "dcf":
                    editor = wx.grid.GridCellTextEditor()
                    renderer = wx.grid.GridCellStringRenderer()
                elif editortype and self.Editable:
                    grid.SetReadOnly(row, col, False)
                    if editortype == "string":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                        if colname == "value" and "length" in editors:
                            editor.SetParameters(editors["length"]) 
                    elif editortype == "number":
                        editor = wx.grid.GridCellNumberEditor()
                        renderer = wx.grid.GridCellNumberRenderer()
                        if colname == "value" and "min" in editors and "max" in editors:
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
                    elif editortype == "float":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif editortype == "bool":
                        editor = wx.grid.GridCellBoolEditor()
                        # editor.SetParameters(BoolList)
                    elif editortype == "access":
                        editor = wx.grid.GridCellChoiceEditor(AccessList, False)
                        # editor.SetParameters(AccessList)
                    elif editortype == "raccess":
                        editor = wx.grid.GridCellChoiceEditor(RAccessList, False)
                        # editor.SetParameters(RAccessList)
                    elif editortype == "option":
                        editor = wx.grid.GridCellChoiceEditor(OptionList, False)
                        # editor.SetParameters(OptionList)
                    elif editortype == "type":
                        if typelist == None:
                            typelist = self.Parent.Manager.GetCurrentTypeList()
                        editor = wx.grid.GridCellChoiceEditor(typelist.split(","))
                        # editor.SetParameters(typelist)
                    elif editortype == "map":
                        if maplist == None:
                            maplist = self.Parent.Manager.GetCurrentMapList()
                        editor = wx.grid.GridCellChoiceEditor(maplist.split(","))    
                        # editor.SetParameters(maplist)
                    elif editortype == "time":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif editortype == "domain":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                else:
                    grid.SetReadOnly(row, col, True)
                    
                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)
                
                grid.SetCellBackgroundColour(row, col, wx.WHITE)