hi i testing wxglcanvas in a aui frame and i get this errors
Traceback (most recent call last):
File "C:\Users\Oscar\Documents\python projcets\CenterWindow.py",
line 27, in OnSize
self.SetCurrent()
File "C:\Python27\lib\site-packages\wx-2.8-msw-ansi\wx\glcanvas.py",
line 112, in SetCurrent
return _glcanvas.GLCanvas_SetCurrent(*args)
wx._core.PyAssertionError: C++ assertion "GetParent()->IsShown()"
failed at ..\..\src\msw\glcanvas.cpp(565) in wxGLCanvas::SetCurrent():
can't make hidden GL canvas current
is the same sample
import wx
import wx.glcanvas as gc
import wx.lib.agw.aui as aui
from OpenGL.GL import *
class World3D(gc.GLCanvas):
def __init__(self, parent, id, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
gc.GLCanvas.__init__(self, parent, id, pos, size, style)
self.init = False
self.size = None
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
def OnEraseBackground(self, event):
pass
def OnSize(self, event):
size = self.size = self.GetClientSize()
if self.GetContext():
self.SetCurrent()
glViewport(0, 0, size.width, size.height)
event.Skip()
def OnPaint(self, event):
dc = wx.PaintDC(self)
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.OnDraw()
def OnMouseMotion(self, event):
pass
def InitGL(self):
glMatrixMode(GL_PROJECTION)
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0)
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
def OnDraw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glBegin(GL_QUADS)
glEnd()
if self.size is None:
self.size = self.GetClientSize()
w, h = self.size
w = max(w, 1.0)
h = max(h, 1.0)
self.SwapBuffers()
class Frame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
self.mgr = aui.AuiManager()
self.mgr.SetManagedWindow(self)
cntr = World3D(self, -1)
self.mgr.AddPane(cntr,
aui.AuiPaneInfo().Name("CenterWindow").Caption("Manage").CenterPane().Dockable(False))
self.mgr.GetPane("CenterWindow").Show()
self.mgr.Update()
app = wx.App()
Frame(None, -1, "Sample").Show()
app.MainLoop()
you can tell me if it works for you?