wxGLCanvas - wxPython unhappy if embedded..

Hi,
I am running wxPython (pyCrust !) embedded inside a wxWindows(C++) App for
more than a year by now - it works great (Thanks Robin ! [and others...])
Now though, I ran into a problem that I could track down as follows:
If I don't create any wxGLCanvas on the C++ side my wxPython class derived
from wxGLCanvas is well behaved.
<code snipplet>
import wx
from wxPython import glcanvas as wxgl
from OpenGL.GL import *
class GLViewer(wxgl.wxGLCanvas):
    def __init__(self, parent, imgArr, size):
        wxgl.wxGLCanvas.__init__(self, parent, -1, size=size)
<snip>
def view(array, title, size):
    frame = wx.Frame(None, -1, title)
    canvas = GLViewer(frame, array, size)
   <snip - sizer stuff>
    return canvas
</code snipplet>

If I run it, I get this:

m = view(arr,'',(100,100))
m

<Priithon.mviewer.GLViewer instance; proxy of C++ wxGLCanvas instance at
_1e96a58_wxGLCanvas_p>

m.GetParent()

<wxPython.frames.wxFrame instance; proxy of C++ wxFrame instance at
_d8b190_wxFrame_p>

type(m.GetParent())

<type 'instance'>

type(m)

<type 'instance'>

But as soon as I put pack the wxGLCanvas on the C++ side, I get an
empty (wxPython) frame with zero height (only title visible) and this
output:

m = view(arr,'',(100,100))
m

<Priithon.mviewer.GLViewer instance; proxy of C++ wxGLCanvas instance at
_10694458_wxGLCanvas_p>

m.GetParent()
type(m.GetParent())

<type 'NoneType'>

type(m)

<type 'instance'>

This is using wx2.4.0 on windows2000. (On Linux(GTK) everything actually
works fine...)

maybe there is a problem with my setup.h ?

I'm thankful for any hints,
Sebastian Haase

Sebastian Haase wrote:

This is using wx2.4.0 on windows2000. (On Linux(GTK) everything actually
works fine...)

maybe there is a problem with my setup.h ?

You'll probably have to tweak your build a bit. In order to not have a startup dependency on the GL libs I don't build wxWindows with the wxGLCanvas included but instead include it in the glcanvasc.pyd along with the Python wrappers. If you are building wxpython the same way then there may be a problem with having two instances of the wxGLCanvas class in the app.

So to change this you should change your setup.h to turn on wxGLCanvas there, and then tweak stuff in setup.py to not build myglcanvas.cpp and in glcanvas.i to not include myglcanvas.h (Or something like that)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!