wx.Frame的Close方法继承自何处?

#/usr/bin/python

#-*-<coding=UTF-8>-*-



"""

此示例主要向大家展示如何在一个框架中添加对象;

wxPython 2.6章节示例讲解

"""



import wx



class InsertFrame(wx.Frame):



    def __init__(self,parent,id):

      wx.Frame.__init__(self,parent,id,title="Frame with button",size=(300,100))

      #在wx.Frame中创建一个panel控件

      panel = wx.Panel(self)

      #在wx.Panel中创建一个Button控件

      button = wx.Button(panel,label="close",pos=(125,10),size=(50,50))

      #绑定按钮的单击事件,注意是将wx.Frame绑定到OnCloseMe事件上,而不是其它对象

      self.Bind(wx.EVT_BUTTON,self.OnCloseMe,button)

      #绑定窗口的关闭事件

      self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)



    def OnCloseMe(self,event):

      #close方法是从哪里来的,看了一下API,wx.Frame好像没有Close()方法?

      self.Close(True)

      print self.Close.__doc__

        

      """

        Close(self, bool force=False) -> bool



        This function simply generates a EVT_CLOSE event whose handler usually

        tries to close the window. It doesn't close the window itself,

        however.  If force is False (the default) then the window's close

        handler will be allowed to veto the destruction of the window.

      """



    def OnCloseWindow(self,event):

      #Destroy()方法只有wx.App才有,为什么wx.Frame也可以调用,此处不明白?

      self.Destroy()

      print self.Destroy.__doc__



      """

        Destroy(self) -> bool



        Destroys the window safely.  Frames and dialogs are not destroyed

        immediately when this function is called -- they are added to a list

        of windows to be deleted on idle time, when all the window's events

        have been processed. This prevents problems with events being sent to

        non-existent windows.



        Returns True if the window has either been successfully deleted, or it

        has been added to the list of windows pending real deletion.

      """   



if __name__ == "__main__":

    app = wx.PySimpleApp()

    frame = InsertFrame(parent=None,id=-1)

    frame.Show()

    app.MainLoop()

你可能感兴趣的:(frame)