Calling tcl from python and viceversa

Cameron Laird claird at lairds.com
Sat Jul 19 23:06:12 EDT 2003


In article <fbf8d8f2.0307191605.268f0b04 at posting.google.com>,
dan <danbmil99 at yahoo.com> wrote:
>funny -- first look at the board and it's right on subject.
>
>I'm trying to write an app that does some cool stuff with sound
>samples, using tkSnack.  But I'm stuck on a simple question -- how do
>I insert some of my own code into the tkInter mainloop?  I need the
>sequencer to run in the background while the UI is up.
>
>Forgetting about snack for the moment, how do I run _any_
>non-event-driven code while my Tk widgets are active? (for instance,
>animation in one window while menus are still available).  I can't
>find any demos that show this sort of behavior.
>
>All the Tk examples I've seen set up the widgets and run
>root.mainloop().  I can't for the life of me figure out what code this
>call invokes, but it won't return until a quit command or some such
>action is initiated by the user.  TCL docs say that Tk_mainloop calls
>tcl_DoOneEvent() in a dead loop until a quit flag is set, or something
>like that.
>
>My best guess is that I'm supposed to set up another thread to do my
>stuff, and send messages to the Tkinter thread that trigger Tk events,
>or something like that.  But the Tkinter docs are so sketchy I can't
>really get a handle on how to do it.  Any help or pointers would be
>appreciated.
			.
			.
			.
In Tcl-think, one just lives with the "dead loop".  There
is no "non-event-driven code".  Tcl-ers go about as far as
anyone with this model.  "[A]nimation in one window while
menus are still available"?  The conventional Tcl response
is, "make the animation event-driven".  I know how unaes-
thetic that will seem to most readers; study <URL: http://
wiki.tcl.tk/GUIAlive > for its full, native expression.

Tcl has added thread support over the last few years--but
not in the standard distribution.  I've never seen a Tkinter
over a threading Tcl; I don't know how well it works.  Maybe
it's just what you're after.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html




More information about the Python-list mailing list