KillSwitch wrote:
I have a C++ program, with a GUI, into which I have embedded python. I
have made several python functions in C++, one of which I use to
override the normal stdout and stderr so that they print to a text box
of my GUI. One thing I cannot think of how to do is to redefine stdin
so that it pauses the program, waits for a user to type input into the
box, hit enter, and takes input from another text element and sends it
to python like it was the console.
I wonder if anyone could help me in trying to do such a thing. To
simplify, the new stdin should wait for the C++ function to give it a
value, like it waits for the console.
I suspect you don't really want to redirect stdin, but instead implement
raw_input(). If you have control over the script, just change it from
raw_input() to cpp_raw_input(). But if you need to be able to run
arbitrary scripts, ...
(untried) - Try changing __builtins__.raw_input to reference your new
function.
DaveA
--
http://mail.python.org/mailman/listinfo/python-list