import os from enthought.pyface.timer.api import Timer from enthought.mayavi.core.api import Engine from enthought.mayavi.sources.vtk_file_reader import VTKFileReader from enthought.mayavi.modules.surface import Surface vtkFile = 'simple.vtk' # Create the MayaVi engine and start it. engine = Engine() engine.start() scene = engine.new_scene() # Read in VTK file and add as source reader = VTKFileReader() reader.initialize(vtkFile) engine.add_source(reader) # Add Surface Module surface = Surface() engine.add_module(surface) # Update class class Updater(object): def __init__(self, filename, reader): self.filename = filename self.reader = reader self.mod_time = os.stat(filename).st_mtime def test_file(self): mod_time = os.stat(self.filename).st_mtime if self.mod_time == mod_time: return print "Data File Changed" self.mod_time = mod_time reader = self.reader reader.reader.modified() reader.update() # Create Updater updater = Updater(vtkFile, reader) timer = Timer(500, updater.test_file) # Create a GUI instance and start the event loop. # This stops the window from closing from enthought.pyface.api import GUI gui = GUI() gui.start_event_loop()