Multiprocess wxPython + Panda3D

Hi everybody,
you can’t imagine how happy I am having this one finally solved. I proudly present wxPython and Panda3D running in separate Processes with proper resizing, cleanup on closing, and mouse- and keyboard focus.

By running both the GUI and Panda3D in separate processes you gain multiple advantages:

  • Multicore support
  • Framerate independence
    (slow game won’t make GUI freeze)
  • Code encapsulation
    (especially comes handy when it comes to Panda’s builtins magic)
  • Crash safety (When Panda crashes because of Python exceptions, the GUI is still running and you could e.g. stop Panda and show a nice debugging dialog)

The only disadvantage is that you have to use a pipe for communication between Panda and wx. That said, if you want Panda to react to a button in wx you have to put a request into the pipe from wx, read it through a task in Panda and call appropriate action there. I can provice an example if anybody’s interested.

EDIT: up to date code on gist.github.com/3586720

Have fun!

Updated version:

gist.github.com/3586720

  • now initializes itself as soon as the top most window shows up
  • cleaned up
  • self-contained
  • module with integrated test

Very impressive.

Thank you very much.

Updated the code snippet on GitHub to also support Windows and extended it to show a text input under Panda3d viewport.

Enjoy

Could anybody test it under Mac, please?

Firstly - thanks for sharing. Very usefull snippet!

Secondly - without this line wp.setForeground(True) i can’t get focus back on linux (Mint, cinnamon). May be do something like

        if os.name != 'nt':
            wp.setForeground(True)