Skip to content

Instantly share code, notes, and snippets.

@fmorency
Created July 3, 2012 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmorency/3042862 to your computer and use it in GitHub Desktop.
Save fmorency/3042862 to your computer and use it in GitHub Desktop.
VTK close event filter
class CloseEventFilter(QObject):
def eventFilter(self, target, event):
if event.type() == QEvent.Close:
for w in target.children():
if hasattr(w, 'close'):
w.close()
return True
return False
#Usage example:
#
#...
#qframe1 = QFrame()
#qframe2 = QFrame()
#qframe1.installEventFilter(ev_filter)
#qframe2.installEventFilter(ev_filter)
#vtk_interactor1 = QVTKRenderWindowInteractor(parent=qframe1)
#vtk_interactor2 = QVTKRenderWindowInteractor(parent=qframe2)
#...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment