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()
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()
def run(self, para=None): table = TableLogManager.get(para['tab']) table.save_tab(para['path'], '\t')
def load(self): n = len(TableLogManager.get_titles()) if n > 0: return True IPy.alert('No table opened!') return False
def table(cls, title, data, cols=None, rows=None): cls(IPy.curapp, TableLogManager.name(title), data, cols, rows).Show()
def OnClosing(self, event): TableLogManager.close(self.title) event.Skip()
def add_tab(self, title, key, unit): titles = TableLogManager.get_titles() self.add_choice(titles, str, title, key, unit) self.para[key] = titles[0] return True
def run(self, para=None): if para['name'] == 'All': for i in TableLogManager.get_titles(): TableLogManager.close(i) else: TableLogManager.close(para['name'])
def load(self): TableKiller.para = {'name': 'All'} titles = ['All'] + TableLogManager.get_titles() TableKiller.view = [(list, titles, str, 'Name', 'name', 'selected')] return True