Pygame embedded in wxPython - 1.5
I've been looking into getting wxPython working with Pygame for a while now, as one of my future projects will involve a fairly complicated interface which would be far too difficult to implement using Pygame alone. Unfortunately this was easier said than done as there appears to be just one example on combining the two, and it's far from perfect - it doesn't show how you would have Pygame running constantly (just how to play a video), and closing the window throws several errors.
So, after a lot of faffing around with messy code and duelling with screens of error messages, I've managed to get this basic demo working. It's not entirely finished yet as there's no real event handling involved (I haven't decided whether it would be best to let wx handle all events or to try and get Pygame to process the ones occurring within its window), but I hope it'll make the process of combining Pygame and wxPython a bit easier. Any comments are welcome, and give me a shout if any problems crop up.
This version is now fully cross-platform, thanks to a patch by randomeyes which makes Pygame draw to a surface and then pass it to wx as an image rather than initialising an SDL display. This approach also makes it possible to have multiple Pygame displays running at once, as shown in the demo.
Demo instructionsUse the slider to control the line density in the pattern displayed. Resizing the window will also resize the pattern accordingly (hooray for wxPython and its resizeable windows!). Click the incredibly tempting 'do not press' button to open a second window with another Pygame display (which may contain flashing lights :P ), in which you can click to add points which will slide down across the display. Yes, it's the most hideous thing ever conceived, but at least it works!
If you wish to leave a comment, please sign in first.