~ubuntu-branches/ubuntu/hardy/mayavi2/hardy-backports

« back to all changes in this revision

Viewing changes to enthought.mayavi/examples/nongui.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-07-25 09:03:34 UTC
  • mfrom: (2.2.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080725090334-1hbb9fn8b3as5qy0
Tags: 2.2.0-1~hardy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
"""This script demonstrates how one can use the MayaVi framework
4
4
without displaying MayaVi's UI.  Note: look at the end of this file to
5
5
see how the non gui plugin is chosen instead of the default gui
6
 
mayavi plugin.
 
6
mayavi plugin. This should be run as:
 
7
 
 
8
  $ python nongui.py
 
9
 
 
10
Or:
 
11
  $ mayavi2 script.py
7
12
 
8
13
"""
9
14
# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
10
15
# Copyright (c) 2005, Enthought, Inc.
11
16
# License: BSD Style.
12
17
 
13
 
# On systems with multiple wx installations installed, pick one that works
14
 
# with the libraries Mayavi depends on.
15
 
try:
16
 
    import wxversion
17
 
    wxversion.ensureMinimal('2.6')
18
 
except ImportError:
19
 
    pass
20
 
 
21
18
# Standard library imports
22
 
import sys
23
 
from os.path import join, dirname
 
19
from os.path import join, abspath
24
20
 
25
21
# Enthought library imports
 
22
from enthought.mayavi.scripts.util import get_data_dir
26
23
from enthought.mayavi.app import Mayavi, NONGUI_PLUGIN_DEFINITIONS
27
24
 
28
 
 
29
25
class MyApp(Mayavi):
30
26
    def run(self):
31
27
        """This is executed once the application GUI has started.
48
44
        script.new_scene()
49
45
 
50
46
        # Read a VTK (old style) data file.
51
 
        r = VTKFileReader()
52
 
        r.initialize(join('data', 'heart.vtk'))
 
47
        r = VTKFileReader()        
 
48
        r.initialize(join(get_data_dir(abspath(__file__)),
 
49
                          'heart.vtk'))
53
50
        script.add_source(r)
54
51
 
55
52
        # Put up some text.