Pygame event problem
anandpillai6 at yahoo.com
Wed Sep 25 11:02:49 EDT 2002
I wrote a simple image viewer in python using pygame image api. The
is in wxPython. There are 2 classes, one for the window frame and one
the pygame image processing.
I added an effect in the pygame class which is called from a menu
wxPython GUI. Here is the code of the GUI class which makes the
def OnLiquidEffect(self, event):
#imgview is of type MyPyGameImgViewer which is the pygame
#class used to load the images.
Here is the method which it calls on the MyPyGameImgViewer class.
anim = 0.0
if self.imgfile is not None:
self.flag = 0
bitmap = pygame.Surface((self.h, self.w))
bitmap.blit(self.screen, (0, 0))
print self.h, self.w
anim = anim + 0.4
for x in range(0, self.h, 20):
for y in range(0, self.w, 20):
xpos = (x + (sin(anim + x * .01) * 15))
ypos = (y + (sin(anim + y * .01) * 15))
self.screen.blit(bitmap, (x, y), (xpos,
ypos, 20, 20))
#I think this code will remove all the
#events from the queue once it detects
#a mouse event.
print "No image loaded!"
The effect is stopped by clicking with the mouse on the pygame
window. My problem is that if I try to invoke any other menu methods
main GUI frame *without doing this*, the application ie both the
the pygame display window, hangs.
I have a gut-feeling that this is because I am calling a method on
the MyPyGameImgViewer class without exiting the while loop.
Is there a way around this, ie to call any method in the
from the GUI class, while one of its methods is executing a while loop
More information about the Python-list