Hello, im new in Python so im hoping to to get some help to figure out what is going wrong.
Im trying to run a Pygames from within wxPython panel (made on Boa Constructor).
To do that i followed the instructions on the http://wiki.wxpython.org/IntegratingPyGame but still it isn't working.
Here is the Panel code that was used to make the integration:
class PG_panel(wx.Panel):
def __init__(self, ID, name, parent, mypos, mysize):
# pygame is imported in this class
# make it globally available
global pygame
#self.Fit()
wx.Panel.__init__(self, id=wxID_FRMMAINPANELTABULEIRO, name='panelTabuleiro', parent=self, pos=(16, 96), size=mysize)
# pygame uses SDL, set the environment variables
os.environ['SDL_WINDOWID'] = str(self.GetHandle())
os.environ['SDL_VIDEODRIVER'] = 'windib'
# do the pygame stuff after setting the environment variables
import pygame
pygame.display.init()
# create the pygame window/screen
screen = pygame.display.set_mode(464, 464) #(424,450)
# start the thread instance
self.thread = PG_thread(screen)
self.thread.start()
def __del__(self):
self.thread.stop()
And im trying to use that panel on an interface from Boa Constructor, here is the code:
class frmMain(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRMMAIN, name='frmMain', parent=prnt,
pos=wx.Point(660, 239), size=wx.Size(815, 661),
style=wx.DEFAULT_FRAME_STYLE, title='Grupo 1 - Jogo de Damas')
self._init_utils()
self.SetClientSize(wx.Size(799, 623))
self.SetBackgroundColour(wx.Colour(225, 225, 225))
self.SetMinSize(wx.Size(784, 650))
self.Center(wx.BOTH)
self.SetMenuBar(self.menuBar1)
#here begins my code
mysize = (464, 464)
mypos = (16, 96)
self.panelTabuleiro = PG_panel(wxID_FRMMAINPANELTABULEIRO, 'panelTabuleiro', self, mypos, mysize)
The original that was auto-made by the Boa Constructor is the following:
self.panelTabuleiro = wx.Panel(id=wxID_FRMMAINPANELTABULEIRO,
name='panelTabuleiro', parent=self, pos=wx.Point(16, 96),
size=wx.Size(464, 464), style=wx.TAB_TRAVERSAL)
self.panelTabuleiro.SetBackgroundColour(wx.Colour(232, 249, 240))
self.panelTabuleiro.SetThemeEnabled(True)
self.panelTabuleiro.SetHelpText('Tabuleiro')
The error that it gives is:
Type error: in method 'new_Panel', expected argument 1 of type 'wxWindow*1
Exception AttributeError: "'PG_panel' object has no attribute 'thread' in ignored
Any thoughts ? I appreciate any help.
Thank you.