wx.Frame的Close方法繼承自何處?

來源:互聯網
上載者:User
#/usr/bin/python#-*-<coding=UTF-8>-*-"""此樣本主要向大家展示如何在一個架構中添加對象;wxPython 2.6章節樣本講解"""import wxclass 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()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.