txversion Executable | |||
Appendix B, Toxik Executables |
Viewing Information and Error Messages
Python scripting in Toxik is implemented by extending the Python language (http://www.python.org). Since Toxik is written in the C++ programming language, this means that we wrote some libraries that allow us to bind our C++ functions to equivalent Python functions. The result is the Toxik Python API. With Python and the Toxik Python API installed, you can write scripts to automatically perform certain repetitive managerial tasks and creative work on a project, such as creating compositions, adding nodes to it, importing material, publishing, rendering, and so on. Access to the API, is simply done with a statement in the script. Once imported, functions from selected modules, like database.openDb(), can be used.
Because a project is not shareable, it must not be opened by more than one Toxik application at a time. It is important that you know that a Python script using Toxik functions is indeed a Toxik application, in the same way that the interactive application is. So when running a script, make sure that the project is not opened by another application.
Note: Since there is no way to prevent someone from opening the same project using a different instance of Toxik, it is your responsibility to make sure it does not happen.
Some scripts may output some information or error messages during execution. All output explicitly printed by the script writer goes to the script console, which is a pop-up window with one line of text. New text overrides any previous text. When the scripts complete, the window closes. If there were errors during the script execution, another window is displayed, containing information or the stack trace that was generated when the error occurred. Information and error messages are displayed by default, but you can turn them off in the user preferences.
In the taskbar, click your user name to open the User Preferences window.
Select the Embedded Scripting tab.
Deselect any of the following:
Script Console (Show)--Controls whether the script console is displayed when the script executes.
Post Execution Message Box (Show Only on Errors)--In addition to errors, displays all outputs that were produced.
Standard Output (Captured)--Normal messages are captured. If capture is disabled, messages go to the shell on Linux. On Windows, messages are lost.
Standard Error (Captured)--Error messages are captured. If capture is disabled, messages go to the shell on Linux. On Windows, messages are lost.
Since it not possible to run an external python script while a project is opened by an application, embedded scripting lets you circumvent this by letting you run Python scripts within Toxik.
Some operations, like Archive and Restore are implemented as Python scripts. So when you use either operation, the embedded interpreter runs Python code seamlessly with the C++ code. No conflict arises since the embedded script is part of the same process as the interactive application.
Some operations, like Render in background, are also implemented as Python scripts, but this particular script does not run embedded. When you start a render operation, the application creates an archive of the composition and then launches an external process (which is the equivalent of running a distinct application) to run the render script. This is possible because the render script does not need to open the project file.
Thanks to embedded scripting, you can also write and execute your own custom scripts within the application. The scripts can be located anywhere in the file system. Toxik recognizes the files ending in .py as Python scripts and identifies them with a thumbnail that represents the Python logo.
In the Import Browser (Ctrl + I), navigate to your custom script.
Right-click your script and do any of the following:
Edit Script -- Opens a text editor so you can edit your script. The text editor is determined by the EDITOR environment variable.
Run -- Executes the script.
Run with Parameters -- Opens a dialog box for typing in parameters before starting the script.