当我按下按钮时,我想将按钮标签打印到 excel 中,创建了 excel 文件,但我无法在其中发送任何信息!有人可以帮助我,还是我做错了?
import wx
from xlwt import *
w = Workbook()
ws1 = w.add_sheet('sheet 1')
class MyFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Button to Excel', size = (300,300))
panel=wx.Panel(self)
extBtn = wx.Button(panel, label="Exit",pos=(100,150))
extBtn.Bind(wx.EVT_BUTTON, self.onClose)
btn = wx.Button(panel,label = "Mem 1",pos=(100,100))
btn.Bind =(wx.EVT_BUTTON,self.onButton)
def onClose(self, event):
self.Close()
def onButton(self,event):
print self.GetLabel() in ws1
if __name__ == '__main__':
app=wx.PySimpleApp()
frame=MyFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()
w.save('a.xls')