printf を使用して stdout に出力する単純な C モジュールを作成しました。
// sample.c
func_print()
{
printf("Hello World!\n");
}
後で、Python プログラムでもSWIG
使用できるように、これを使用してラッパーを作成しました。func_print
このプログラムでは、stdout を textctrl ウィジェットにリダイレクトしました。期待どおり、使用してprint
印刷したものはすべて、textctrl ウィジェットに正しく印刷されます。
# sample.py
...
sys.stdout = textctrl # textctrl is a TextCtrl widget (wxPython).
print 'Hello from Python!' # prints in the textctrl widget, as expected.
ただし、func_print()
(sample.py から) C 関数を呼び出すと、textctrl ウィジェットではなく端末に出力されます。
func_print() # [Problem] prints to the terminal window, instead of the textctrl widget.
どういうわけか、stdout
C モジュールの for 関数が期待どおりにリダイレクトされないようです。これを修正するのを手伝ってください。ありがとうございました。