Created
May 7, 2016 20:43
-
-
Save dgobbi/285270a0bd3125e9b251e28af58140f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a simple class that can catch errors from VTK objects. | |
""" | |
import vtk | |
class ErrorObserver: | |
def __init__(self): | |
self.__ErrorOccurred = False | |
self.__ErrorMessage = None | |
self.CallDataType = 'string0' | |
def __call__(self, obj, event, message): | |
self.__ErrorOccurred = True | |
self.__ErrorMessage = message | |
def ErrorOccurred(self): | |
occ = self.__ErrorOccurred | |
self.__ErrorOccurred = False | |
return occ | |
def ErrorMessage(self): | |
return self.__ErrorMessage | |
e = ErrorObserver() | |
a = vtk.vtkImageReader() | |
a.AddObserver('ErrorEvent', e) | |
print "doing update" | |
a.Update() | |
if e.ErrorOccurred(): | |
print e.ErrorMessage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment