Revision 4eaf0dce8350a336dd310a788f96f236db7f0d7f authored by Eh Tan on 08 September 2008, 19:18:16 UTC, committed by Eh Tan on 08 September 2008, 19:18:16 UTC
1 parent b20f4d7
OpenCitcomSFILES.py
# Standard library imports.
from os.path import isfile
# Enthought library imports.
from enthought.pyface import FileDialog, OK
# Local imports
from enthought.mayavi.script import get_imayavi
from enthought.mayavi.core.common import error
from enthought.mayavi.action.common import WorkbenchAction, get_imayavi
######################################################################
# `OpenCitcomSHDFFile` class.
######################################################################
class OpenCitcomSHDFFILE(WorkbenchAction):
""" An action that opens a new HDF5 file. """
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self):
""" Performs the action. """
wildcard = 'HDF5 timestep files (*.*.h5)|*.*.h5|' + FileDialog.WILDCARD_ALL
parent = self.window.control
dialog = FileDialog(parent=parent,
title='Open CitcomS HDF5 timestep file',
action='open', wildcard=wildcard
)
if dialog.open() == OK:
if not isfile(dialog.path):
error("File '%s' does not exist!" % dialog.path, parent)
return
from citcoms_plugins.plugins.CitcomS_hdf_file_reader import CitcomSHDFFileReader
r = CitcomSHDFFileReader()
r.initialize(dialog.path)
mv = get_imayavi(self.window)
mv.add_source(r)
Computing file changes ...