Scripting panel»
If you feel ready to create or use a Python script to automate tasks in your type design process, you can start by opening the Scripting panel Window > Panels > Scripting. The panel is more powerful than the Macro panel in FontLab Studio 5. Not only does it have a toolbar and editor like the old Macro panel, it also has an interactive Python shell console.
The local toolbar of the Scripting panel allows you to perform the following actions:
Open the Local Menu»
When you click the button you will see a menu:
The commands in this menu let you perform standard file operations with your scripts:
- New Script closes the currently opened script and clears the panel’s contents allowing you to start a new script
- Open Script closes the current script and opens the standard Open dialog box allowing you to select and open the script file
- Save Script saves changes to the currently opened script
- Save Script As saves the current script to a new file
- Clear Python Context resets the Python dictionary state before running every new script.
- Clear Python Context Now resets the Python dictionary state.
Run Scripts»
To run the currently edited script, click the triangle button.
Search»
Use this to search within the currently opened script.
Open the List of scripts»
Click the first button on the right-hand side of the Scripting panel’s local toolbar to open the List of scripts. The List of scripts may include folders containing your script files. Remember that it will be empty until you add some folders here.
To add a folder with scripts, click the + button. In the standard Open dialog box, select the folder with scripts and click Open. You can add any folder from your hard disk. If it contains at least one file with a .py extension it will appear in the Scripts list:
Any scripts you add here will become available in the Scripts Menu, from where you can run them quickly without opening the Scripting panel.
To remove a folder with all its scripts, select it in the list and click the – button.
To update the list contents (after you moved or renamed script files in Finder), click the “Refresh folders” button.
To open a script, simply double-click it in the list.
Open the Output panel»
Click the second button on the right to open the Output panel which can show you the results of your macro program interpretation.
Open the Console panel»
Click the last button in the Scripting panel’s local toolbar to open the Python Console. This is the interactive Python shell where you can communicate with Python using the command line.
Unlike the commands you write in the editor that need to be run before you see any response, you can enter Python commands in the Console and get an immediate response.
For example, type
import sys [Return]
print sys.version [Return]
You will see the version number of your current Python:
Similarly, typing “help(fontgate)” will give you quick help information for the fontgate module.