Calling tcl from python and viceversa

dan danbmil99 at yahoo.com
Sun Jul 20 02:05:28 CEST 2003


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.

thanks in advance - stumped


cpitaar at yahoo.com.ar (Carlos P.) wrote in message news:<453d10b2.0307190828.3c576f15 at posting.google.com>...
> Hi!
> I want to call tcl from python and python from tcl. The big picture is
> that I´m writing an application GUI with tcl/tk and application logic
> with python, so at least I want to call python events from the tk GUI.
> I have read about _tkinter and tkapp.call although I couldn´t find any
> detailed documentation. And, anyway, that seems to work in one
> direction (python->tcl) but I don´t know how to make it work in the
> other (tcl->python).
> Thank you,
> Carlos




More information about the Python-list mailing list