Beispiel #1
0
    def __init__(self, parent, title, data, cols=None, rows=None):
        wx.Frame.__init__(self, parent, -1, title)
        TableLogManager.add(title, self)
        self.data, self.cols, self.rows = data, cols, rows
        tableBase = GenericTable(data, cols, rows)
        self.grid = wx.grid.Grid(self)
        self.grid.SetTable(tableBase)
        self.grid.AutoSize()

        menus = [('File(&F)', [('Save as tab', self.OnSaveTab),
                               ('Save as csv', self.OnSaveCsv), ('-'),
                               ('Exit', self.OnClose)]),
                 ('Help(&H)', [('About', self.OnAbout)])]

        menuBar = wx.MenuBar()
        for menu in menus:
            m = wx.Menu()
            for item in menu[1]:
                if item[0] == '-':
                    m.AppendSeparator()
                else:
                    i = m.Append(-1, item[0])
                    if item[1] != None:
                        self.Bind(wx.EVT_MENU, item[1], i)
            menuBar.Append(m, menu[0])
        self.SetMenuBar(menuBar)
        self.Fit()
Beispiel #2
0
    def __init__(self, parent, title, data, cols=None, rows=None):
        wx.Frame.__init__(self, parent, -1, title)
        TableLogManager.add(title, self)
        self.data, self.cols, self.rows = data, cols, rows
        tableBase = GenericTable(data, cols, rows)
        self.grid = wx.grid.Grid(self)

        ## create tablegrid and set tablegrid value
        #self.grid.SetTable(tableBase)
        self.grid.CreateGrid(len(data), len(data[0]))
        if cols != None:
            for i in range(len(cols)):
                self.grid.SetColLabelValue(i, cols[i])
        if rows != None:
            for i in range(len(rows)):
                self.grid.SetColLabelValue(i, rows[i])
        for i in range(len(data)):
            for j in range(len(data[0])):
                self.grid.SetCellValue(i, j, str(data[i][j]))
        self.grid.AutoSize()

        ## create menus
        menus = [('File(&F)', [('Save as tab', self.OnSaveTab),
                               ('Save as csv', self.OnSaveCsv), ('-'),
                               ('Exit', self.OnClose)]),
                 ('Help(&H)', [('About', self.OnAbout)])]

        ## bind the menus with the correspond events
        menuBar = wx.MenuBar()
        for menu in menus:
            m = wx.Menu()
            for item in menu[1]:
                if item[0] == '-':
                    m.AppendSeparator()
                else:
                    i = m.Append(-1, item[0])
                    if item[1] != None:
                        self.Bind(wx.EVT_MENU, item[1], i)
            menuBar.Append(m, menu[0])
        self.SetMenuBar(menuBar)
        self.Fit()