I have an annoying issue that I have not been able to solve for the past few months. Basically, I'm using jupyter/ipython notebook to call pyqt and display 3d geometric data. This is how I initialize the app into an object and after I add some polygons and points, I call show():
class Figure(object):
'''
Main API functions
'''
def __init__(self):
print "... initializing canvas ..."
self.app = QApplication(sys.argv)
self.app.processEvents()
...
def show(self): #Show
self.GUI = GLWindow(data)
self.app.exec_()
I'd like to continuously interact/update the widget through the notebook cells. But once I call the show() command in the jupyter notebook I can't run any more cells or update the widget as the notebook output gets queued (?) and locked out:
#Initialize figure object inside the notebook
fig = plb.figure()
...
fig.show() #Locks out any further jupyter commands while widget on screen
fig.update() #Does not get executed until widget is closed
It seems the .show() function called through the notebook gives up control of the python kernel (?) but it's unclear how to get it back, and also how to then connect it to the widget being displayed.
Mouse and keyboards events do interact with the widget, but they use intrinsic functions like mouseMoveEvent() that are inside the widget code:
class GLWindow(QtGui.QWidget):
def __init__(self, fig, parent=None):
QtGui.QWidget.__init__(self, parent)
self.glWidget = GLWidget(fig, parent=self)
...
class GLWidget(QtOpenGL.QGLWidget):
def __init__(self, fig, parent=None):
QtOpenGL.QGLWidget.__init__(self, parent)
...
def mouseMoveEvent(self, event):
buttons = event.buttons()
modifiers = event.modifiers()
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
...
I've tried to follow related suggestions but I don't understand how to use connections or events outside of the widget.
Any help is appreciated, I've spent so many hours on trying to fix this it's embarrassing. Cat