wxPython launching PyGame window ?

thal thal at kahala.net
Tue Aug 27 05:25:49 EDT 2002


Hi - can anyone help a newbie who is trying to launch a module
which uses PyGame from a module which uses wxPython?

The problem I have is that when the Pygame window launches,
everything is fine until I close that window - either from the top
right corner 'X' or by using the Escape key - I get a message from
Win 95 saying the program has "performed an illegal operation".

Am I making an elementary Python newbie mistake ?

Thanks in advance...

Neil Winterman




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

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

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
#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()

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()



####################################################
Traceback (most recent call last):
  File "<stdin>", line 26, in ?
  File "C:\PYTHON22\lib\site-packages\wxPython\wx.py", line 1587, in
__init__
    _wxStart(self.OnInit)
  File "<stdin>", line 23, in OnInit
TypeError: 'module' object is not callable
10:12:11 PM: Debug: c:\Projects\wx\src\msw\app.cpp(535):
'UnregisterClass(canvas)' failed with error 0x00000000 (the operation
completed successfully.).
10:12:11 PM: There were memory leaks.
10:12:11 PM: ----- Memory dump -----
10:12:11 PM: wxFrame at $FF5378, size 332
10:12:11 PM:
10:12:11 PM:
10:12:11 PM: ----- Memory statistics -----
10:12:11 PM: 1 objects of class wxFrame, total size 332
10:12:11 PM:
10:12:11 PM: Number of object items: 1
10:12:11 PM: Number of non-object items: 0
10:12:11 PM: Total allocated size: 332
10:12:11 PM:
10:12:11 PM:





More information about the Python-list mailing list