21.01.2015 Views

wxPython in Action - 错误提示:发生了异常

wxPython in Action - 错误提示:发生了异常

wxPython in Action - 错误提示:发生了异常

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.6.1 <br />

2.8wx.FrameInsertFrameclose<br />

2.3InsertFrame<br />

2.3<br />

#!/usr/b<strong>in</strong>/env python<br />

import wx<br />

class InsertFrame(wx.Frame):<br />

def __<strong>in</strong>it__(self, parent, id):<br />

wx.Frame.__<strong>in</strong>it__(self, parent, id, ’Frame With Button’,<br />

size=(300, 100))<br />

panel = wx.Panel(self) #<br />

button = wx.Button(panel, label=”Close”, pos=(125, 10),<br />

size=(50, 50)) #<br />

#<br />

self.B<strong>in</strong>d(wx.EVT_BUTTON, self.OnCloseMe, button)<br />

#<br />

self.B<strong>in</strong>d(wx.EVT_CLOSE, self.OnCloseW<strong>in</strong>dow)<br />

def OnCloseMe(self, event):<br />

self.Close(True)<br />

def OnCloseW<strong>in</strong>dow(self, event):<br />

self.Destroy()<br />

if __name__ == ’__ma<strong>in</strong>__’:<br />

app = wx.PySimpleApp()<br />

frame = InsertFrame(parent=None, id=-1)<br />

42 / 565

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!