How to use WxPandaWindow?

Hi,

The WxPandaWindow seems to be quite new, however, I did not find an example how to use it together with Showbase.

From some other examples it seems like I have to configure Pande using

loadPrcFileData('startup', 'window-type none')

to suppress the creation of a new window by Showbase. But it looks like that no camera is created as well, so my scene is not shown when I use a WxPandaWindow later.

Example code:

import wx

from panda3d.core import loadPrcFileData
loadPrcFileData('startup', 'window-type none')

from direct.showbase import ShowBase
base = ShowBase.ShowBase()
base.startWx()

print base.cam

from direct.wxwidgets.WxPandaWindow import WxPandaWindow

foo = base.loader.loadModel('teapot')
foo.reparentTo(base.render)
foo.setPos(0, -20, 10)


class MainWindow(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, 'Test', size=(300, 200))

        panel1 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
        panel2 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)

        panel1.SetBackgroundColour("BLUE")
        panel2.SetBackgroundColour("RED")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel1, 2, wx.EXPAND)
        sizer.Add(panel2, 1, wx.EXPAND)
        self.SetSizer(sizer)

        panelSizer = wx.BoxSizer(wx.VERTICAL)

        self.window1 = WxPandaWindow(parent=panel1)
        panelSizer.Add(self.window1, 1, wx.EXPAND)
        panel1.SetSizer(panelSizer)

        self.Layout()
        self.Show(True)

mw = MainWindow(None)

run()

The line

print base.cam

prints out None, so it seems like no camera is created. If I remove the call to loadPrcFileData then the camera is created, however, a new window is also created, together with the embedded WxPandaWindow.

Could someone provide a hint here?

The camera is created at the time your WxPandaWindow is created. You are printing out base.cam before that happens. Try moving the print statement to the end of your file (after you have created your MainWindow object, for instance).

David