Threads and subprocesses

Lego Andy me at andy.cx
Tue Mar 13 10:30:30 EST 2001


Hello!

I am trying to make execute program from tkinter while still having control over user
interface.

So I tried with combination of threads and os.popen.
Well, it kind of works.

So what I did is this:

done=IntVar()
done.set(1)

def Display(fp, done):
   while not done.get():
	line = fp.read(1)
	if not line:
		break
	print line,

fp = os.popen("some program", 'r')
tr=threading.Thread(target=Display, args=(fp, done))
tr.start()

Now the question is:

Let say that this is done when you press Start. Then when you press Stop, it should
stop executing. Well, I tried by closing fp and I get segfault. I tried killing thread,
but I cannot find any way of doing that. Please help me.


					Andy

--
 /\  |  | |~\  \  /      ------------------------------------------------
/  \ |\ | |  |  \/      / e-mail: andy at x0.org  )\._.,--....,'``.
|--| | \| |  |  /      /  ICQ: 27889915       /,   _.. \   _\  (`._ ,.
|  | |  | |_/  /      /   http://andy.x0.org  `._.-(,_..'--(,_..'`-.;.'
----------------------                                  



More information about the Python-list mailing list