通過乙個例項來看看如何控制wxpython的輸出,並觀察各必要物件的建立次序及生命週期。
#執行一下看看:!/usr/bin/env python
#-*- coding: utf-8 -*-
'''function:簡單的wxpython程式
input:none
output: none
author: socrates
blog:
date:2012-07-01
'''import
sys
import
wxclass
myframe(wx.frame):
'''建立乙個frame類
'''def
__init__
(self, parent, id, title):
print u"
frame物件初始化(frame _init__)
"wx.frame.
__init__
(self, parent, id, title)
class
'''
'''def
__init__(self, redirect = true, filename =none):
print""
__init__
(self, redirect, filename)
defoninit(self):
print u"
"self.frame = myframe(parent = none, id = -1, title = u"
測試wxpyhont輸出重定向")
self.frame.show()
self.settopwindow(self.frame)
print >> sys.stderr, u"
輸出到標準錯誤控制台。
"return
true
defonexit(self):
print u"
"def
main():
開始重定向
print u"
begin mainloop
"
print u"
after mainloop"if
__name__ == '
__main__':
main()
由上面的輸出也可以看到各物件的生命同週期,建立先後順序:
frame._init()
輸入重定向,正確輸出重定向,錯誤輸出重定向
一 標準輸入 stdin a.輸入重定向 標準輸入 作用 將原先鍵盤輸入的內容改由檔案內容代替 root wenwen cat test.txt asdas asdas asdas 按crtl d 退出 將network內容匯入到test.txt中去 root wenwen cat test.txt...
Linux重定向(輸入輸出重定向)
我們知道,linux 中標準的輸入裝置預設指的是鍵盤,標準的輸出裝置預設指的是顯示器。而本節所要介紹的輸入 輸出重定向,完全可以從字面意思去理解,也就是 通常是用檔案或命令的執行結果來代替鍵盤作為新的輸入裝置,而新的輸出裝置通常指的就是檔案。對於輸入重定向來說,其需要用到的符號以及作用如表 1 所示...
重定向Trace輸出
把以下 copy到工程中的任何乙個cpp檔案中,則trace輸出的資訊會在任何notepad檔案中輸出。class cmfxtrace extern cmfxtrace thetracer class cmfxtrace public cfile private constructor public...