A wxWindows pod for Panda3D [v.2009-05-05]

The idea is to have a startup shell (I call it ‘pod’) to begin from scratch a panda3d application using the power of Wxwidgets to ease as much as possible the job.
The stuff is known to work on panda3D 1.5.4 and 1.6.x on a linux desktop and on windowsXP with python 2.5 or 2.6 and WxWidgets 2.7.8 and 2.8.9

Download the package here:
p3dwxpod.zip

Create a folder on your hard disk and unpack into it the whole stuff and start it using run.sh on linux or run.bat on windows or issuing from console

python p3dwxpod.py

Enjoy.

I should point out that there’s a similar thing to this available already in the Panda3D source code. It’s called the WxAppShell and it will be available in 1.6.0 and later. This code looks more or less like the WxAppShell though – what is exactly the difference between them?

[size=92]I should also mention that (in case you took code from either the WxAppShell or the Panda3D Editor from the other thread) the BSD license (afaik) does not permit relicensing (even if you specify “no license”) with or without modified code.[/size]

Yes i saw it and that inspired me this but this it very different - that was an empty wx shell with just a base.userExit() P3D code and mine is a complete and working environment where you can start from scratch coding you P3D app without doing anything else. I hope the fact it have a similar menu and about messagebox will not raise licensing issues…
Anyway I’m curious to know what David think about it

No, don’t worry. I didn’t notice this class actually also shows a Panda3D window inside the Wx window. It looks useful to start with.

Thanks! Very nice example. I notice that when the about dialog shows, panda3d is no longer updated.

thankyou Laurens.
Yes indeed is so 'cos the about messagebox is opened in blocking mode - closing it you’ll start again where you were so you won’t miss anything of your app.

thank you very much astelix!
i’m sure, i’ll find use for that code :slight_smile:

8) this is what I hope for - good coding and dont forget to share it to us

That’s why I spawn modal dialog in a new thread.

I have used your code well, thanks for it.
I created a wx.Frame decendant which allows you to have multiple frames open on the same or different parent window.
I have finally managed to set up a nodepath attached to the camera node of each frame upon which a gui is rendered with scale set like aspect2d to duplicate the wx coordinate system.
Also I have attached a 3d model underneath the mouse cursor (or in place of) which, along with the other hud items (which are soon to be click3d/drag3dable) is also parented under the perspective lense of the frames camera nodepath to allow 3d scenes to look more realistic when viewed as hud items.

The source will be put to use in my current project ($) so I wont be releasing it unles you post which specific project of yours it is for.

Next I plan to find a way to autogenerate all of the widget classes using the other half of the project - an app designer/compiler which uses my panel3d for the interface. I am planning on using a ZUI.

I actually ain’t get where you are planning to go Derek, but sound you’re starting something big. I’m looking forward to see it when you got some to show.
About my piece of code, it is not intended to develop any particular project but to have a generic starting point to build p3d apps with the commodity of wxWindows library and as less effort as possible.
Soon I’ll post an update with new stuff so stay tuned!

nice stuff Derek! this is something I would do by myself sooner or later but if you got some to share do not hesitate to send me or post here - if I think that could be useful I’ll fit into the project.

People, as I said before I got a first less drafty revision of this snippet. I have tons of ideas to add but for now I guess could be a nice start.
Check the first post of this thread, download and play and maybe tellme what you think about.

A new version is up - beside several fixes now it runs nice on windows as well as linux.
Go here to download the stuff.

I just tried the new version and it segfaults:

patrick@t40puter:~/Desktop/p3dwxpod$ python p3dwxpod.py 
DirectStart: Starting the game.
:util: Reading /home/patrick/Desktop/p3dwxpod/config/p3dwxpod.prc
>>>opening p3dsurface
:display: loading display module: libpandagl.so
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadWindow (invalid Window parameter)
:display:glxdisplay(error): BadDrawable (invalid Pixmap or Window parameter)
:display:glxdisplay(error): BadValue (integer parameter out of range for operation)
Segmentation fault

My own panda-only stuff is working fine. Now, I’ve been having some issues with graphics drivers since I upgraded to Ubuntu 9.04 (Jaunty Jackalope) so that might be the cause.

I’m getting similar errors too (GLXBadDrawable), it happens because panda’s window gets reparented before the wx window is fully opened.
In p3dwxpod.py, replace the line that says “self.init_end()” with something like this:

    taskMgr.doMethodLater(0.5, self.init_end, "blah", extraArgs=[])

That makes sure it opens 0.5 seconds later. Would be cleaner to have an onOpen event or so.

PS. Nice work, the wxpod. I like it. Maybe we should have something like this in pview. :slight_smile:

squish the bug correctly pointed out by the always precious pro_rsoft has gone, BUT looks like there is more: in my rig 2 (see my signature) the Ubuntu flavor, I can’t say if it is a matter of something changed in the P3D 1.6 or the ATI drivers but I’m experiencing a bad behavior whit the Panda overlay (either using my pod or the usual panda window) revealing out whatever window I put in front of it and therefore the wx menus are not visible 'cos are covered by the P3d overlay. Download again the pod and see for yourselves.

hey thankyo dude, I’m glad you like it - would you believe I started to make it to replace pview? then the little snippet has grown since then - it is under the hood of my p3ddojo - but it is open enough to make any kind of p3d app.

@astelix: In fact that’s the very problem I was talking about (with graphics drivers), I also have an ATI card (and I can’t do anything about it, it’s a laptop…). I filed this bug if you want to take a look: bugs.freedesktop.org/show_bug.cgi?id=21600

Thanks for this wonderful class! I’ve found a bug, on linux at least:

In p3dwxpod.py, line 169:

    if self.wxevt_loop.Pending(): self.wxevt_loop.Dispatch()

Should be:

    while self.wxevt_loop.Pending(): self.wxevt_loop.Dispatch()

This bug causes menu interaction to be painfully slow.

Thanks again!