def __init__(self, parent, title, data, cols=None, rows=None):
wx.Frame.__init__(self, parent, -1, title)
logopath = os.path.join(root_dir, 'data/logo.ico')
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) )
self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO))
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.Bind(wx.EVT_CLOSE, self.OnClose)
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()
评论列表
文章目录