I have a substantial wxpython-based application that I'm trying to port from python-2 to -3. Almost everything is working properly, except for a few small but important sections that use the OGL library. That executes without any exceptions, but the objects created within the diagram/canvas/panel are invisible! {sometimes they are visible for a small fraction of a second}. This occurs on Windows-10 and on Linux(Debian) systems. The colored background and buttons render just fine, the buttons do what they should, but no objects appear on the background (again, only with Py3, Py2 works properly).
I have cut the code to a pretty minimum set and will attempt to paste it to the bottom of this message in the hope that it will encourage one of you to see what the problem might be. Alternatively if anyone knows of an example that works with Python-3 I'd be delighted to learn of it. Thanks for any insights!! # --------------------------------------------- # togl.py test 'OGL' shape system. from __future__ import print_function import sys if 2 == sys.version_info.major : import wxversion import wx import random import wx.lib.ogl as ogllib NOMSIZE=80 WINSIZE=400 N_ITEMS=7 shapeTypes= ( 'rect', 'circle', 'rndRect' ) class ShapeGraphicWindow(ogllib.ShapeCanvas): def __init__(self, parent): ogllib.ShapeCanvas.__init__(self, parent) self.diagram= ogllib.Diagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.SetBackgroundColour(wx.BLUE) def addShape(self, shape_type, title) : if 'rect' == shape_type : # rectangle shape= ogllib.RectangleShape(50, 35) brush= wx.Brush(wx.TheColourDatabase.Find("RED"), wx.SOLID) elif 'circle' == shape_type : # circle shape= ogllib.CircleShape(65) brush= wx.Brush(wx.TheColourDatabase.Find("YELLOW"), wx.SOLID) elif 'rndRect' == shape_type : # rounded-rectangle shape= ogllib.RectangleShape(45, 30) shape.SetCornerRadius(-0.3) brush= wx.Brush(wx.TheColourDatabase.Find("GOLDENROD"), wx.SOLID) else : raise AssertionError("Unable to add shape: %s : %s",(shape_type,title)) shape.SetBrush( brush ) x= int(random.uniform(NOMSIZE,WINSIZE-NOMSIZE)) shape.SetX(x) y= int(random.uniform(NOMSIZE,WINSIZE-NOMSIZE)) shape.SetY(y) shape.AddText(title) print("Draw",title,"at location ", (x,y), "on canvas of size", self.GetSize()) shape.SetCanvas(self) self.AddShape(shape) self.Refresh() shape.Show(True) return class TestPanel(wx.Panel): def __init__(self, frame) : wx.Panel.__init__(self, parent=frame) self.objcnts= (0,N_ITEMS) sz= wx.BoxSizer(wx.VERTICAL) hsz= wx.BoxSizer(wx.HORIZONTAL) btnq= wx.Button(self, -1, "Quit") btnq.Bind(wx.EVT_BUTTON, self.Quit) hsz.Add(btnq, 0, wx.ALL, 3) btnq= wx.Button(self, -1, "AutoTest") btnq.Bind(wx.EVT_BUTTON, self.AutoTest) hsz.Add(btnq, 0, wx.ALL, 3) sz.Add(hsz, 0, wx.ALIGN_LEFT) self.shp_graph_win= ShapeGraphicWindow(self) sz.Add(self.shp_graph_win, 2, wx.EXPAND) self.SetSizer(sz) #self.Layout() #self.Fit() self.SetAutoLayout(True) def mkTitle(self, index) : return ''.join([ chr(index + ord('A')), ":", str(index) ]) def AutoTest(self, event=None) : for j in range(*(self.objcnts)) : self.shp_graph_win.addShape(shapeTypes[j % len(shapeTypes)], self.mkTitle(j)) self.objcnts= (self.objcnts[1], self.objcnts[1]+N_ITEMS) def Quit(self, event) : self.Destroy() sys.exit(0) class TestFrame(wx.Frame): def __init__(self) : wx.Frame.__init__(self, None, -1, "test basic OGL functionality", size= wx.Size(WINSIZE,WINSIZE) ) TestPanel(self) self.Show(True) app = wx.App(False) frame = TestFrame() ogllib.OGLInitialize() app.MainLoop() sys.exit(0) -- https://mail.python.org/mailman/listinfo/python-list