Multi threading

I’m trying to get a GUI going with my game, mostly for debugging and that kind of stuff, but I ran into the very common issue where my game hangs on the initialization of tkinter. So I had to look into threading, which is apparently very easy in Python.

I’m using the Programming Python books, by Mark Lutz (O’REILLY pub) and it’s got a fairly good look at the basic concepts so far. Here’s something I wrote for myself, that I used to get a decent handle of threads, using the threads module in py2.6. What it does it changes the color of the background in the pygame window, and when you open the tkinter window, you can set that color in real time, without any hangs. It’s pretty neat, and I’m looking forward to adding it into my main game.

I’m still sorta getting the hang of lambdas only because it does seem to look right to me, even if I use them properly. I’ve got a line that goes:

root.bind('<Return>', (lambda event: printEnt(ent)))

And I don’t know why

event

isn’t given properly and there’s no exception raised…

 

Oh well, there’s always tomorrow.

Leave a Reply

Your email address will not be published.