Home » Support » Index of All Documentation » Wing IDE Reference Manual » Scripting and Extending Wing IDE »
15.1. Getting Started
Scripts are Python modules or packages containing one or more Python functions. When Wing starts up, it will search all directories in the configured Script Search Path for modules (*.py files) and packages ( directories with an __init__.py file and any number of other *.py files or sub-packages).
Wing will load scripts defined in each file and add them to the command set that is defined internally. The script directories are traversed in the order they are given in the preference and files are loaded in alphabetical order. When multiple scripts with the same name are found, the script that is loaded last overrides any loaded earlier under that name.
Naming Scripts
Scripts can be referred to either by their short name or their fully qualified name (FQN).
The short name of a script is the same as the function name but with underscores optionally replaced by dashes (cmdname.replace('_', '-')).
The FQN of a script always starts with .user., followed by the module name, followed by the short name.
For example, if a script named xpext_doit is defined inside a module named xpext.py, then the short name will be xpext-doit and the FQN will be .user.xpext.xpext-doit.
Reloading Scripts
Once script files have been loaded, Wing watches the files for changes on disk and automatically reloads them as needed. As a result, there is usually no need to restart Wing when working on a script, except when a new script file is added. In that case, Wing will not load the new script until the reload-scripts command (Reload All Scripts in the Edit menu) is issued or the IDE is restarted.
For details on how reloading works, see Advanced Scripting.
Overriding Internal Commands
Wing will not allow a script to override a command that Wing defines internally (those documented in the Command Reference). If a script is named the same as a command in Wing, it can only be invoked using its fully qualified name. This is a safeguard against completely breaking the IDE by adding a script.
One implication of this behavior is that a script may be broken if a future version of Wing ever adds a command with the same name. This can generally be avoided by using appropriately descriptive and unique names and/or by referencing the command from key bindings and menus using only its fully qualified name.
| « 15.0. Scripting Example | Table of Contents | 15.2. Script Syntax » |
