[IPython-dev] Re: [SciPy-dev] Generic gui_thread + IPython: solution already exists!

Prabhu Ramachandran prabhu_r at users.sf.net
Tue Nov 16 01:57:21 EST 2004


>>>>> "FP" == Fernando Perez <Fernando.Perez at colorado.edu> writes:

    >> BTW, does this version of FC ship with threaded versions of
    >> libtcl/libtk/_tkinter?  If it does, I am at a loss.

    FP> Well, here's some more info:

    FP> planck[~]> ldd /usr/lib/libtk8.4.so
[...]

    FP> So it seems that _tkinter has thread support, but NOT tcl/tk.
    FP> Maybe that explains the difference with your box.
    FP> Unfortunately, I can't really offer to do a full separate
    FP> build of tcl/tk/tkinter/python to get a fully threaded setup,
    FP> that would take _waaaay_ more time than I can spend on this.

Hmm, actually, it looks like there are even subtler issues!  Darn!
>From what I understand, only when thread.start() is invoked does the
threading actually begin.  So in all my earlier code Tkinter is
imported (along with a Tcl interpreter underneath) inside the main
thread and NOT the gui_thread!  This is what caused all the headache
for you.

I tried a simple fix for this but it looks like if Tcl is itself
threaded (as in my case) it must be in the main thread!  Thus, I'd
need to make two different versions, one that works on threaded tk's
and one on non-threaded tk's.  Pain!

I have to run now.  Will try to send a patch tonight so you can test
it out for the non-threaded setups.

    FP> But it does piss me off to know that it's a stupid
    FP> distribution issue!  Your debian success proves that it _can_
    FP> work!  Do you know of any reason why Fedora would do the
    FP> tcl/tk builds without thread support, other than moronism?

No clue.

    >> Anyway, I think the only way out of this mess would be to add a
    >> -tk flag.  I've just done that.  So you can do -{g,w}thread
    >> without -tk and you should see no problems.  If you have decent
    >> Tcl/Tk/tkinter build or a good OS ;-) then you could risk
    >> trying '-tk'.  I've made a patch for this and attached it
    >> below.  The code isn't the greatest but works for me.  So to
    >> enable Tk do `ipython -{g,w}thread -tk`.

    FP> Yes, the -tk separate flag would certainly be a necessity.  I
    FP> can always fold this into offering -gthread AND -gthreadtk
    FP> (similar for -wthread), so people only need to pass a single
    FP> option to activate all thread/gui stuff.  I can unpack them
    FP> inside myself.  But this will have to be strongly documented,
    FP> since it's so easy to get a broken, segfaulting setup.

Yes.

    FP> I'm seriously starting to envy debian...

:)  

    FP> Thanks again!  Do you think you'll tweak this further, or
    FP> should I consider this last patch final?  I'm in no hurry.

No, not final.  We need to do more stunts here.  I'll mail the list a
patch tonight that I'd appreciate if someone with a non-threaded Tcl
can test with.  Then we can change things suitably.

cheers,
prabhu




More information about the IPython-dev mailing list