[Tutor] Popen and Prompting

Faulconer, Steven M. STEVEN.M.FAULCONER at saic.com
Tue Aug 30 22:51:51 CEST 2005


Hello all,

Been digging through the web and the archives for the tutor list and can't
seem to locate an answer to my question. It is probably out there, but my
searching skills are failing me. I recently wrote a GUI for several command
line programs using Tkinter. Everything is working quite well, until I ran
into one program that actually prompts for some input. I'm currently using
os.popen to make the actual calls. Something like:

--------- Code ----------
input = popen( command, 'r' )
while 1:
	line = input.readline()
	if not line:
		break
	<deal with the data>
--------- Code ----------

My question for all of you python people; how can I handle programs that MAY
need input from the command line. I thought about using something like
pexpect, but the input requests are fairly variable, and may not show up at
all. Also, I need to tie this in with the Tkinter GUI as well. The binaries
we are running are written in C, and we have no way of changing that (it's
in-house software, but the API we have to use does not talk to Python). I've
attached the program in all it's glory, so general advice (constructive
only, please) would be greatly appreciated.

Target Platform is Windows (2000/XP)
Python Version 2.4.x

Thanks for any advice you can send along,
Steven

-------------- next part --------------
A non-text attachment was scrubbed...
Name: GuiCheck_b.pyw
Type: application/octet-stream
Size: 35038 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20050830/a59b0ee2/GuiCheck_b-0001.obj


More information about the Tutor mailing list