Hi Kene, I had a similar issue with OCC display initialization (I use tabs in my application, each of which contains a QtGui.QMainWindow).
To avoid issues with the display initialization I use Qt signals to initialize the OCC display _after_ the Qt GUI has initialized and is displayed. In class ViewerMainWindow(QtGui.QMainWindow): --------------------------------------------------------- def __init__(self): self.graphicsView = MyQtViewer3d(self.viewer_centralwidget) # derived from qtViewer3d self._graphicsinitialized = False self.connect(self.graphicsView, QtCore.SIGNAL("sigGraphicsInitialised"), self.slotGraphicsInitialised) def AssertGraphicsInitialized(self): # This fucntion will be called each time the application switches # to the viewer window. Using this function occ graphics driver initialization is delayed until the # viewer window is displayed the first time to ensure the GUI has already been # created upon graphics driver initialization. if not self._graphicsinitialized: self.graphicsView.InitDriver() def slotGraphicsInitialised(self): self._graphicsinitialized = True self.SetDefaultBackground() In class class MyQtViewer3d(qtViewer3d) --------------------------------------------------------- def InitDriver(self): qtViewer3d.InitDriver(self) self._display.EnableAntiAliasing() self.SetupTrihedron() self.context=self._display.GetContext().GetObject() # AIS_InteractiveContext self.emit(QtCore.SIGNAL("sigGraphicsInitialised"), ()) Which Qt signal you could use to trigger a call to AssertGraphicsInitialized depends on your application of course. You might also try to simply override the paintEvent method: def paintEvent(self, event): QtGui.QMainWindow.paintEvent(self, event) self. AssertGraphicsInitialized() Hope this helps, Mark Am 29.03.2013 um 02:57 schrieb Kene Meniru: > Hi: > > I am creating an app which customizes QtGui.QMainWindow. I am using > splitters to split my screen into four areas and have the following code in > my __init__ definition to create tabs in one of the areas: > > ----- start code > > # Create TabWidget > self.viewArea = QtGui.QTabWidget() > # Add tabs > self.modelTab = modelview.ModelView(self) > self.reportTab = QtGui.QTextBrowser() > self.viewArea.addTab(self.modelTab, "Model") > self.viewArea.addTab(self.reportTab, "Report") > self.modelTab.InitDriver() > > ------ end code > > The modelview module contains the code provided below but it does not work > for me. It produces the following messages and dies with a "Segmentation > fault". > > ###### 3D rendering pipe initialisation ##### > Display3d class initialization starting ... > Graphic device created. > > I would like to load the OCCViewer in the modelTab so that I can use > pythonOCC in that tab. > > Any help will be sincerely appreciated. Thanks. > > ----- start modelview module code > > from PyQt4 import QtGui > import OCCViewer > > > class qtBaseViewer(QtGui.QWidget): > ''' The base Qt Widget for an OCC viewer > ''' > def __init__(self, parent=None): > super(qtBaseViewer, self).__init__(parent) > self._display = None > self._inited = False > self.setMouseTracking(True) # enable Mouse Tracking > self.setFocusPolicy(QtCore.Qt.WheelFocus) # Strong focus > self.setAttribute(QtCore.Qt.WA_PaintOnScreen) > self.setAttribute(QtCore.Qt.WA_NoSystemBackground) > > def GetHandle(self): > return int(self.winId()) > > def resizeEvent(self, event): > if self._inited: > self._display.OnResize() > > > class ModelView(qtBaseViewer): > def __init__(self, *kargs): > super(ModelView, self).__init__(*kargs) > self._drawbox = False > self._zoom_area = False > self._select_area = False > self._inited = False > self._leftisdown = False > self._middleisdown = False > self._rightisdown = False > self._selection = None > > def InitDriver(self): > self._display = OCCViewer.Viewer3d(self.GetHandle()) > self._display.Create() > self._display.DisplayTriedron() > self._display.SetModeShaded() > self._inited = True > print "Inited!!" > > ----- end modelview module code > > > -- > > Kene > :::::::::::::::::: > kemen...@gmail.com > > > _______________________________________________ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users _______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users