Tkinter and printf in C ...

Bengt Richter bokr at accessone.com
Mon Jul 9 12:08:43 EDT 2001


On Mon, 09 Jul 2001 13:49:58 +0800, Chyr-Pyng Su
<cpsu at larc.ee.nthu.edu.tw> wrote:

>>
>> __________________________________________________________________
>
>I have considered this method os.popen() before. I think this method is best used
>when
>the C programs and the Python GUI are independently seperate program. But this is
>not
>for my situation. Since I want to process the data from the C function and also
>monitor
>the its message... :p
>
I'm still not sure what your situation is ;-)

What do you mean by "its message" ? Stuff that used to go to stdout
and/or stderr (both? or which?) the way it ran originally?

Have you got the rest of the problem solved? (I.e., passing
the function arguments and getting "the data").

Is it a huge C program that is impractical to change at the
points where "messages" are generated? Or could you change
the interface to pass the function a call-back routine and
change it to use that instead of printf/fprintf?

Have you considered a hack like #define printf blah-blah
to change  what your C function does where it makes "messages"?

Have you considered writing your own stdio write function
and linking that statically with the C function in a DLL
to capture writes to stdout and stderr?

Where do the "messages" go if you don't try to capture them?
To a console ("DOS") window? (BTW is your platform Windows?)

Do you have other output going to stdout/stderr from your
Python program (e.g., plain print or fwrite to stdout/stderr)
that you don't want to interfere with? If not, and all of
your program's output to stdout/stderr is from your C function,
maybe it would be possible to catch your own program's output
via a pipe (not popen, but similar).

There are a lot of possibilities, but if you want very specific
help you have to be very specific about what you need, best
stated it in terms of your real goal, not a sub-goal. I.e.,
if you want to get across a river, don't ask about a problem
building suspension bridges or concrete spans. The answer may
be a rowboat or wading across a shallow place upstream ;-)




More information about the Python-list mailing list