| 1 |
# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
|
| 11 |
# fixme: |
| 12 |
# - Get custom tree view images. |
| 13 |
# - Write a program to create a directory structure from a lesson plan file. |
| 14 |
|
| 15 |
""" Script to run the tutorial. |
| 16 |
""" |
| 17 |
|
| 18 |
|
| 19 |
import os |
| 20 |
import sys |
| 21 |
|
| 22 |
from traitsui.extras.demo import demo |
| 23 |
|
| 24 |
# Correct program usage information: |
| 25 |
usage = """ |
| 26 |
Correct usage is: tutor.py [root_dir] |
| 27 |
where: |
| 28 |
root_dir = Path to root of the tutorial tree |
| 29 |
|
| 30 |
If omitted, 'root_dir' defaults to the current directory.""" |
| 31 |
|
| 32 |
|
| 33 |
def main(root_dir): |
| 34 |
# Create a tutor and display the tutorial: |
| 35 |
path, name = os.path.splitext(root_dir) |
| 36 |
demo(dir_name=root_dir, title='Traits Demos') |
| 37 |
|
| 38 |
|
| 39 |
if __name__ == "__main__": |
| 40 |
|
| 41 |
# Validate the command line arguments: |
| 42 |
if len(sys.argv) > 2: |
| 43 |
print(usage) |
| 44 |
sys.exit(1) |
| 45 |
|
| 46 |
# Determine the root path to use for the tutorial files: |
| 47 |
if len(sys.argv) == 2: |
| 48 |
root_dir = sys.argv[1] |
| 49 |
else: |
| 50 |
root_dir = os.getcwd() |
| 51 |
|
| 52 |
main(root_dir) |