9.2 TRICKS

  1. Set the directory where a script is found as the current working directory

    Start your script with the following:

    chdir(__file__)
    
    When executing a script, pyFormex sets the name of the script file in a variable __file__ passed with the global variables to the execution environment of the script.

  2. Import modules from your own script directories

    In order for Python to find the modules in non-standard locations, you should add the directory path of the module to the sys.path variable.

    A common example is a script that wants to import modules from the same directory where it is located. In that case you can just add the following two lines to the start of your script.

    import os,sys
    sys.path.insert(0,os.dirname(__file__))
    

  3. Automatically load plugin menus on startup

    Plugin menus can be loaded automatically on pyFormex startup, by adding a line to the gui section of your configuration file (~/.pyformexrc).

    [gui]
    plugins = ['surface_menu', 'formex_menu']
    

  4. Automatically execute your own scripts on startup

    If you create your own pugin menus for pyFormex, you cannot autoload them like the regular plugin menus from the distribution, because they are not in the plugin directory of the installation.9.2You can however automatically execute your own scripts by adding their full path names in the autorun variable of your configuration file.

    autorun = '/home/user/myscripts/startup/'
    
    This script will then be run when the pyFormex GUI starts up. You can even specify a list of scripts, which will be executed in order. The autorun scripts are executed as any other pyFormex script, before any scripts specified on the command line, and before giving the input focus to the user.

  5. Create a movie from a sequence of recorded images

    The multisave option allows you to easily record a series of images while working with pyFormex. You may want to turn this sequence into a movie afterwards. THis can be done with the mencoder and/or ffmpeg programs. The internet provides comprehensive information on how to use these video encoders.

    If you are looking for a quick answer, however, here are some of the commands we have often used to create movies.



Footnotes

... installation.9.2
Do not be tempted to put your own files under the installation directory (even if you can acquire the permissions to do so), because on removal or reinstall your files might be deleted!