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

Re: [pygame] Pygame Surfaces in wxPython



Platform specific message loop problems of mixing pygame an wxPython
notwithstanding for the moment, it's pretty easy to get a pygame
surface into a wxPython bitmap by using a string as an intermediate.
Basically something like this:

        image_string = pygame.image.tostring(pygame_surface, "RGB")
        imgWx = wx.EmptyImage(image.get_width(), image.get_height())
        self.SetClientSize((image.get_width(), image.get_height()))
        self.SetMinSize(self.GetSize())
        imgWx.SetData(image_string)
        wx_bitmap = imgWx.ConvertToBitmap()

then bitmaps can be drawn to the PaintDC for the window with dc.DrawBitmap


On Jan 20, 2008 10:59 PM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
> Hi,
>
> I'm making a specialized paint program to deal with weird paint functions.
> The idea is that programmers want paint programs to be able to do things
> that they can't.  For example, this program can make three channel
> heightmaps using a greyscale image.  It can draw the red or green or blue
> sections of an image in any combination or separately.  Etc.  Feel free to
> email me for any other suggestions.
>
> Anyway, the problem.  This program should use Pygame Surfaces because they
> are great and I know how to work with them.  I'm using wxPython chiefly
> because of its menu support.  I figured out after much deliberation of
> solutions and hassle over implementing them how to make menus and
> subwindows.  I want to place Pygame Surfaces into these windows.  Does
> anyone have any idea how to do that?
>
> Thanks,
> Ian
>