[Tkinter-discuss] How to dettach a Toplevel

Sorin Schwimmer sxn02 at yahoo.com
Fri Dec 1 18:30:01 CET 2006


> This sounds like you try to start Tk from a child thread ?
> I guess that is something one should never do; maybe you could change
> this, so Tk runs in the main thread and the job in the child thread.

> I hope this helps

> Michael

No, it doesn't :-(

I used the following test code:

<code>
#! /usr/bin/python

from time import sleep
import sys,os,thread
from Tkinter import *

def one_th():
  sys.stderr.write('In the thread...\n')

if os.fork()==0:
  os.setsid()
  if os.fork()==0:
    sys.stdin=open('/dev/null','r')
    sys.stdout=open('/dev/null','w')

    thread.start_new_thread(one_th,())
    while True:
      sleep(60)
      try:
        rtk=Tk(screenName=':0.0')
      except:
        continue
      break
    Label(rtk,text='It works').grid()
    sys.stderr.write('Entering mainloop\n')
    rtk.mainloop()

  sys.exit(0)
</code>

I can see on root's console "In the thread...", and, after a while, "Entering mainloop", but
nothing shows up in user's screen.

Maybe it's simply impossible...

Sorin




 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061201/577a834f/attachment.html 


More information about the Tkinter-discuss mailing list