November 28th, 2003, 02:01 PM
problems with tkinter, are while loops possible?
im making a very simple game where right now the controllable character is a rectangle on a canvas. i bound function for the movement to the arrow keys, and the rectangle is moved by canvas.move()
my problem is that i want the arrow keys to simple change the direction of the movement and have the rectangle always move in that direction without key presses. so i tried a while loop which seemed like the natural solution, but the problem is the entire loop has to be executed before the window is created and while 1: loops make it freeze. is there any solution to this?
November 28th, 2003, 05:18 PM
while loops are possable in GUI's , that i do know! I guess what you should be doing is calling your 'move this way' function inside your while loop.. if you have some code i'll take a look
Oh, in Python 2.3+ you should use the True keyword instead of 1 (as long as you arnt bothered about back compatability), so your while loop should look like this..
Also, if you want to make games with Python can i suggest you try Pygame, its allot more powerful and this is what it was built for!
November 28th, 2003, 05:59 PM
i know of pygame, i learned a bit and to be honest i dont like it a lot. for this simple game i know i can avoid it. heres thing the thing, there is no while loop. in tkinter, the only way i know of making things work is in events, and i tried puting a while loop in an event but again its as if the loop finishes in one go and and then everything is displayed, its in explicable. does anyone ahve any experience with this?