8.4.5 Functions defined in the script module

Globals( )
Return the globals that are passed to the scripts on execution.

This basically contains the globals defined in draw.py, colors.py, and formex.py, as well as the globals from numpy. It also contains the definitions put into the pyformex.PF, by preference using the export() function. During execution of the script, the global variable __name__ will be set to either 'draw' or 'script' depending on whether the script was executed in the 'draw' module (-gui option) or the 'script' module (-nogui option).

export( dic)
Export the variables in the given dictionary.

export2( names,values)
Export a list of names and values.

forget( names)
Remove the global variables specified in list.

rename( oldnames,newnames)
Rename the global variables in oldnames to newnames.

listAll( clas=None,dic=None)
Return a list of all objects in dic that are of given clas.

If no class is given, Formex objects are sought. If no dict is given, the objects from both GD.PF and locals() are returned.

named( name)
Returns the global object named name.

ask( question,choices=None,default='')
Ask a question and present possible answers.

If no choices are presented, anything will be accepted. Else, the question is repeated until one of the choices is selected. If a default is given and the value entered is empty, the default is substituted. Case is not significant, but choices are presented unchanged. If no choices are presented, the string typed by the user is returned. Else the return value is the lowest matching index of the users answer in the choices list. Thus, ask('Do you agree',['Y','n']) will return 0 on either 'y' or 'Y' and 1 on either 'n' or 'N'.

ack( question)
Show a Yes/No question and return True/False depending on answer.

error( message)
Show an error message and wait for user acknowlegement.

warning( message)

showInfo( message)

system( cmdline,result='output')
Run a command and return its output.

If result == 'status', the exit status of the command is returned. If result == 'output', the output of the command is returned. If result == 'both', a tuple of status and output is returned.

playScript( scr,name=None,filename=None,argv=[])
Play a pyformex script scr. scr should be a valid Python text.

There is a lock to prevent multiple scripts from being executed at the same time. This implies that pyFormex scripts can currently not be recurrent. If a name is specified, set the global variable GD.scriptName to it when the script is started. If a filename is specified, set the global variable __file__ to it.

If step==True, an indefinite pause will be started after each line of the script that starts with 'draw'. Also (in this case), each line (including comments) is echoed to the message board.

force_finish( )

step_script( s,glob,paus=True)

breakpt( msg=None)
Set a breakpoint where the script can be halted on a signal.

If an argument is specified, it will be written to the message board.

The exitrequested signal is usually emitted by pressing a button in the GUI. In nongui mode the stopatbreakpt function can be called from another thread.

enableBreak( mode=True)

stopatbreakpt( )
Set the exitrequested flag.

playFile( fn,argv=[])
Play a formex script from file fn.

fn is the name of a file holding a pyFormex script. A list of arguments can be passed. They will be available under the name argv. This variable can be changed by the script and the resulting argv is returned to the caller.

play( fn=None,argv=[],step=False)
Play a formex script from file fn or from the current file.

This function does nothing if no file is passed or no current file was set.

exit( all=False)
Exit from the current script or from pyformex if no script running.

processArgs( args)
Run the application without gui.

Arguments are interpreted as names of script files, possibly interspersed with arguments for the scripts. Each running script should pop the required arguments from the list.

formatInfo( F)
Return formatted information about a Formex.

printall( )
Print all Formices in globals()

printglobals( )

printglobalnames( )

printconfig( )

printdetected( )

chdir( fn)
Change the current working directory.

If fn is a directory name, the current directory is set to fn. If fn is a file name, the current directory is set to the directory holding fn. In either case, the current dirctory is stored in GD.cfg['workdir'] for persistence between pyFormex invocations.

If fn does not exist, nothing is done.

workHere( )
Change the current working directory to the script's location.

This function is deprecated: use chdir(_file__) instead.

runtime( )
Return the time elapsed since start of execution of the script.

startGui( args=[])
Start the gui