<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                通過一個實例來看看如何控制wxPython的輸出,并觀察各必要對象的創建次序及生命周期。 ~~~ #!/usr/bin/env python # -*- coding: utf-8 -*- ''' Function:簡單的wxPython程序 Input:NONE Output: NONE author: socrates blog:http://www.cnblogs.com/dyx1024/ date:2012-07-01 ''' import sys import wx class MyFrame(wx.Frame): ''' 創建一個Frame類 ''' def __init__(self, parent, id, title): print u"Frame對象初始化(Frame _init__)" wx.Frame.__init__(self, parent, id, title) class MyApp(wx.App): ''' 創建一個App類 ''' def __init__(self, redirect = True, filename = None): print "APP __init__" wx.App.__init__(self, redirect, filename) def OnInit(self): print u"APP對象的OnInit方法(OnInit)" self.frame = MyFrame(parent = None, id = -1, title = u"測試wxPyhont輸出重定向") self.frame.Show() self.SetTopWindow(self.frame) print >> sys.stderr, u"輸出到標準錯誤控制臺。" return True def OnExit(self): print u"APP對象的OnExit方法" def main(): app = MyApp(redirect = True) #開始重定向 print u"begin MainLoop" app.MainLoop() print u"after MainLoop" if __name__ == '__main__': main() ~~~ 運行一下看看: ![](https://box.kancloud.cn/2016-06-08_5757935e810e0.png) 可見,在APP對象創建之后(__init__方法調用結束),由于指定了重定向功能,所以輸出切換到了stdout/stderr。 由上面的輸出也可以看到各對象的生命同周期,創建先后順序: 1. ? app._init_() 1. ? app.OnInit() 1. ? Frame._init() 1. ? app.MainLoop() 1. ? app.OnExit() 觀察這一句:app = MyApp(redirect = True) #開始重定向: - ? 當redirect為True時,輸出到wxPython框架,此時也可啟用filename來指定輸出到文件。 - ? 當redirect為False時,輸出到控制臺。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看