[Tutor] Question about pygame/tkinter interaction

Chris Fuller cfuller084 at thinkingplanet.net
Tue Jan 20 05:16:01 CET 2009

On Monday 19 January 2009 12:05, Steve Willoughby wrote:
> I have a game I'm porting to Python which is currently written
> using TCL/Tk.  Now it would be fairly easy to make it work in
> Python with Tkinter, of course, since the way the GUI would be
> organized and implemented would be essentially the same.
> However, I'd also like to implement some fancier (but minor)
> animated effects and embed video and audio clips.  So I was
> thinking that pygame (or pymedia) would be reasonable choices,
> but I've never used either of those before.
> Is it reasonable to expect that I could use Tkinter for
> everything else, but use pygame/pymedia to handle things like
> creating a video playback window on the screen, or is pygame
> going to want to run the whole GUI event loop and screen updates
> in competition with Tkinter?
> Any general nudges in the right direction would be appreciated.
> Thanks,
> steve

I have successfully run dual GUI managers at once (Tkinter and wxPython) by 
suspending the mainloop of one and starting the other.  You might be able to 
setup a timeout in one GUI to service pending events in the other if this 
approach would be difficult.

GUIs tend to want to be in the main thread.  Certainly any GUI functions 
called from other threads must be via locks.  You could try experimenting 
with having a thread for each GUI, but I would expect problems.  Another 
solution would be to have two separate Python instances with some form of 
interprocess communications.  This doesn't have to be all that difficult, if 
you are careful with the design.  You can use pickle to convert complex 
objects into strings, for instance.


More information about the Tutor mailing list