[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] my naive interactive pygame



Hi;

I found a way to make the pygame screen refresh during an interactive
session using a thread. This is probably horribly broken in some way,
but it works for me :o)


# interactive_pygame.py
import threading
import time
import pygame

# this is pygsear.examples.penguin
from penguin import *

class PWorker(threading.Thread):
def __init__(self, pygame):
self.pygame = pygame
self.done = 0
threading.Thread.__init__(self)

def run(self):
while not self.done:
self.pygame.display.update()
time.sleep(1)

def stop(self):
self.done = 1

pw = PWorker(pygame)
pw.start()

def killpw():
pw.stop()

import atexit
atexit.register(killpw)

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail