Correction Launching PyGame from wxWindows

thal thal at kahala.net
Tue Aug 27 06:21:31 EDT 2002


Sorry - slight correction:

Neil


#################################################
# wxPygame1.py

from wxPython.wx import *
import os, sys
import pygame, pygame.sprite, pygame.transform, pygame.image
from pygame.locals import *
import MinimalGame


class MyFrame(wxFrame):
    def __init__(self, parent, ID, title):
        wxFrame.__init__(self, parent, ID,
                title, wxDefaultPosition, wxSize(350, 200))


class MyApp(wxApp):
    def OnInit(self):
        frame = MyFrame(NULL, -10,"BasicWinTool")
        frame.Show(true)
        self.SetTopWindow(frame)
        #
        MinimalGame()
        #
        return true
app = MyApp(0)
app.MainLoop()




##################################################
#MinimalGame.py
#MinimalGame.py
import os
import pygame, pygame.font, pygame.image, pygame.mixer
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((800, 800), HWSURFACE|DOUBLEBUF)

background = pygame.Surface(screen.get_size())
background.fill((250, 250, 250))
screen.blit(background, (0, 0))
pygame.display.flip()

Objectimage = os.path.join('data', 'Adenine.gif')

while 1:
    event = pygame.event.poll()
    if event.type == QUIT or (event.type == KEYDOWN and event.key ==
K_ESCAPE):
        break
    OBJECT = pygame.image.load(Objectimage).convert()
    Objectpos = OBJECT.get_rect()
    Objectpos.right = screen.get_height()
    Objectmove = 8

    screen.blit(OBJECT, Objectpos)
    pygame.display.flip()





More information about the Python-list mailing list