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

[pygame] Fw: [wxPython-users] pyGame AND wxPython working on win2k



I repost this here. If somebody can help with this issue....

Riccardo

----- Original Message ----- 
From: "Nathan R. Yergler" <nathan@yergler.net>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, May 07, 2003 16:32
Subject: Re: [wxPython-users] pyGame AND wxPython working on win2k


> I tried the code you provided on Linux and ran into a couple issues.
> First, the SDL_VIDEODRIVER environment variable should only be set to
> windib if sys.platform == 'win32'.  Even then there's an issue I haven't
> figured out how to get around.  If you set the environment variable
> SDL_WINDOWID to the proper window handle, and then call pygame.init()
> within the frame's __init__, you get a Gdk-ERROR that you have specified
> a bad window handle.  It seems that on Linux the window handle isn't
> really there until the constructor finishes.  I suppose you could move
> the initialization code to an OnPaint handler, like the example
> currently in the wiki.  If I get a chance to do some refinement and get
> the code to work on Linux I'll put it in the wiki as a second example.
>
> NRY
>
>
> On Wed, 2003-05-07 at 06:13, Riccardo Trocca wrote:
> > This sample I built works on Win2k too.
> > I'm using the latest stable versions of both pyGame and wxWindows.
> > I've been able to track down the problem of SDL surfaces popping up in
> > another window delaying the "import pygame" statement. It seems that on
> > win2k just importing pygame causes some initialization, preventing the
user
> > to change some parameter like the windowid.
> > Hope that this can be fixed because the code looks really ugly.
> > I could not try it on Linux or other platforms therefore I don't know if
it
> > works at all.
> >
> > Riccardo
> >
> >
> >
> > from wxPython.wx import *
> > import os
> > import thread
> > pyGame=None
> >
> >
> > class SDLThread:
> >  def __init__(self,screen):
> >   self.m_bKeepGoing=self.m_bRunning=False
> >   self.screen=screen
> >   self.color=(255,0,0)
> >   self.rect=(10,10,100,100)
> >  def Start(self):
> >   self.m_bKeepGoing = self.m_bRunning = True
> >   thread.start_new_thread(self.Run, ())
> >  def Stop(self):
> >   self.m_bKeepGoing = False
> >
> >  def IsRunning(self):
> >   return self.m_bRunning
> >
> >  def Run(self):
> >   while self.m_bKeepGoing:
> >    e=pyGame.event.poll()
> >    if e.type==pyGame.MOUSEBUTTONDOWN:
> >     self.color=(255,0,128)
> >     self.rect=(e.pos[0],e.pos[1],100,100)
> >     print e.pos
> >    self.screen.fill((0,0,0))
> >    self.screen.fill(self.color,self.rect)
> >    pyGame.display.flip()
> >   self.m_bRunning=False;
> >
> > class SDLPanel(wxPanel):
> >  def __init__(self,parent,ID,tplSize):
> >   global pyGame
> >   wxPanel.__init__(self,parent,ID,size=tplSize)
> >   self.Fit()
> >   os.environ['SDL_WINDOWID']=str(self.GetHandle())
> >   os.environ['SDL_VIDEODRIVER'] = 'windib'
> >   import pygame
> >   pyGame=pygame
> >   pyGame.display.init()
> >   window = pyGame.display.set_mode(tplSize)
> >   self.thread=SDLThread(window)
> >   self.thread.Start()
> >
> > class MyFrame(wxFrame):
> >  def __init__(self,parent,ID,strTitle,tplSize):
> >   wxFrame.__init__(self,parent,ID,strTitle,size=tplSize)
> >   self.pnlSDL=SDLPanel(self,-1,tplSize)
> >   #self.Fit()
> > app = wxPySimpleApp()
> > frame = MyFrame(NULL, -1, "SDL Frame",(640,480))
> > frame.Show()
> > app.MainLoop()
> >
> > ----- Original Message ----- 
> > From: "Kevin Altis" <altis@semi-retired.com>
> > To: <wxPython-users@lists.wxwindows.org>
> > Sent: Tuesday, May 06, 2003 23:25
> > Subject: RE: [wxPython-users] pyGame
> >
> >
> > > > -----Original Message-----
> > > > From: Nathan R. Yergler
> > > >
> > > > This question comes up a lot.  Attached is some sample code
shamelessly
> > > > cribbed from the list archive
> > > > (http://aspn.activestate.com/ASPN/Mail/Message/1300467) and cleaned
> > > > (only slightly).  I've also created a page in the wiki where I'll
put
> > > > this information.  You can find it at
> > > > http://wiki.wxpython.org/index.cgi/IntegratingPyGame.  Anyone with
> > > > additional information, please put it there so we can have a
centralized
> > > > body of knowledge on this popular topic.
> > > >
> > > > Nathan
> > > >
> > > >
> > > > On Sun, 2003-05-04 at 20:18, Alejandro Adecoar wrote:
> > > > > Is it possible to use the pygame module with wxpython?
> > > > --
> > > > Nathan R. Yergler
> > > > http://yergler.net/~nathan
> > >
> > > This sample doesn't actually work for me. Perhaps the problem is
Numeric,
> > in
> > > which case either a specific version of Numeric needs to be specified
or
> > we
> > > need a much simpler example that doesn't require Numeric.
> > >
> > > C:\mypython\mp3>gradientTest.py
> > > Traceback (most recent call last):
> > >   File "C:\mypython\mp3\gradientTest.py", line 38, in OnIdle
> > >     self.draw()
> > >   File "C:\mypython\mp3\gradientTest.py", line 79, in draw
> > >     column = surfarray.map_array(surface, column)
> > > ValueError: unsupported bytesperpixel for array
> > >
> > > I'm running Windows 2000 (SP3), Python 2.2.2, wxPython 2.4.0.7, PyGame
> > 1.5.5
> > > (binary install), Numeric 22.0. Commenting out the draw lines allows
the
> > > code to run.
> > >
> > > Also, at least on Windows, the PyGame window does not appear in the
> > wxFrame,
> > > which I think is the intent. I'm pretty sure that long ago, maybe
wxPython
> > > 2.3.2 we were able to get the PyGame display to appear in a wxWindow
and
> > the
> > > primary stumbling block is that now that doesn't seem to work. Does it
> > work
> > > correctly on Mac OS X or Linux?
> > >
> > > Another problem is that if you close the PyGame window it will cause
the
> > > Python interpreter to crash.
> > >
> > > I would be really happy if Robin and Pete could get wxPython and
PyGame
> > > co-operating again since then we would be able to play MPEGs and do
some
> > > other display magic in wxPython cross-platform rather than just using
COM
> > on
> > > Windows for multimedia.
> > >
> > > ka
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> > > For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> > For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
> -- 
> Nathan R. Yergler
> http://yergler.net/~nathan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
>