Tkinter and printf in C ...

Chyr-Pyng Su cpsu at larc.ee.nthu.edu.tw
Tue Jul 10 10:18:34 EDT 2001


>

Thanks for you attention... :>

>
> 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?
>

The original C program is a little big. The main problem is that in C program
I use some libraries written by others, those function call will inherently print
some status or data (message) to console in Dos, or terminal in Unix where you
launched the program.
To hack those function call of someone else libraries will waste of lot of time.. :p

>
> 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).
>

Wow.. you have show most of the possibilities... :<>

Now I have wrapped my C program to some function call..
I intend to trigger the C function from Python-ed GUI and process some data,
these function call will dump some status message during the process... and return
some
results to GUI program when it finished. The status message will go to the console if
I dont
capture it.. (I develope the program in Unix environment .. )

All of my program's stdout is from the C functions. Could you give me some hints to
monitor those status message so that  they can be shown on the GUI not just print to
the console or
a terminal...

>
> 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 ;-)

--
 Ĭ«ù¥­   Su, Chyr-Pyng                               o888o V o888o
 VLSI Design, Testing and Fault Tolerance Lab.       o8 ~__   __  8o
 EE. National Tsing Hau Univ. Taiwan                 88o   ooo   o88
                                                        o 8^ ^8 o
 E-Mail: cpsu at larc.ee.nthu.edu.tw                    /- 88_____88 -\
 WWW:    http://larc.ee.nthu.edu.tw/~cpsu            _\   qioip   /_






More information about the Python-list mailing list