Python, Tkinter and popen problem



I have come across a problem that, as I understand all documentation I
have found, should not exist.

Python version is 2.5.2, Tinker in that package.
Linux Slackware 10.2

I went to test os.popen and got mixed answers.

1) IF os.popen opens a command line or command window type
THEN the read and writes work as expected
2) IF os.popen opens a Tkinter contained python program
THEN the read is not consistant and write to it fails.

OK - #1 runs as expected on shell scripts and other programs that were
written for the keyboard and redirectors only. (non GUI types)

#2 popen sometimes connects to stdout OF the child and sometimes
not and has never shown signs of connection to stdin OF child

The Tkinter usage has three (3) print statements. Two (2) never show up.
One does. The one that does is the exit notice.

In the 'child' program; print, sys.stdout.write(string), and os.write(stdout,string) all work for the one that does write back, but
none work for the two that do not. Don't get picky on the syntax, the
purpose is to get the message across.


The print statements are:
print "Notice of action"
print VariableHavingTextOfAction

print "Closing down\n"

Yes I added the '\n' to the others - no change.

Same loop reads/prints the stdout FROM child in all three cases.

All three work fine when Tkinter included program is run 'solo'.
Print statements show up in the text (command, whatever) window.
The entire Tkinter included program runs normally except for the I/O
linkage problem when using os.popen(..... or Popen2.popen2 or ... then
only third print shows up in text window. Acts as if first two prints
were captured but never forwarded to screen. If it was a case of not
sending until a system flush() took place then all three lines would
appear at the closing. That is NOT happening. Only closing notice appears.

The child has a pause expecting a keystroke from the master immediately
following the print VariableH... which apparently is never received.


This is a case of Python running a Python program that contains Tkinter.


So what is going on and what can I do?
I want the master to echo the slave's print statements and the slave get
the 'continue' character so it will.

Today is: 20090519
Versions noted above.

Steve

.



Relevant Pages

  • Python, Tkinter and popen problem
    ... not and has never shown signs of connection to stdin OF child ... The Tkinter usage has three print statements. ... With master having a print ":",returnVal to verify where the text screen notices come from - the final print FROM the child is verified as captured and printed from the master. ...
    (comp.lang.python)
  • Re: Python, Tkinter and popen problem
    ... That's one of the problems - with Tkinter you don't get tiny files. ... I have kept working on this and now have it to the point that sending TO the child w/Tkinter works. ... ALL print statements FROM child do now flush and are shown correctly, but only when the child terminates. ... I don't care how it's flushed as long as it works on whatever machine python runs on. ...
    (comp.lang.python)
  • Re: ANN: PyGUI 2.1
    ... Also these stated goals are what every GUI package should aspire to. ... Develop a GUI API that is designed specifically for Python, ... But even Tkinter needs more details! ... i can't sacrifice the widget set. ...
    (comp.lang.python)
  • Re: Yet another GUI toolkit question...
    ... I think Tkinter is lagging behind Tk itself in terms of its advances ... Certainly a lot of Python developers don't seem well-informed about the ... called "Tile" and will be part of the Tk core when it's released at v. 8.5). ... The vast range of available GUI toolkits is one thing that partially ...
    (comp.lang.python)
  • Re: Yet another GUI toolkit question...
    ... I think Tkinter is lagging behind Tk itself in terms of its advances ... Certainly a lot of Python developers don't seem well-informed about the ... called "Tile" and will be part of the Tk core when it's released at v. 8.5). ... The vast range of available GUI toolkits is one thing that partially ...
    (comp.lang.python)