Skip to content

The VisualApplets Scripting Console#

VisualApplets offers a Scripting Console, in which you can enter Python or Tcl commands.

To open the Scripting Console in VisualApplets:

  1. From menu Window, select Dock Windows and then Scripting Console.

    VA Opening the Scripting Console

    The Scripting Console is immediately opened at the bottom of the VisualApplets program window:

    VA Scripting Console

Using the Scripting Console#

In the Scripting Console, you can switch in the Script Interpreter drop-down list, whether you want to use Python or Tcl as scripting language:

VA Scripting Console: Switching Scripting Languages

The Scripting Console has the following fields:

VA Scripting Console

  1. Enter your command into the input field and strike the Return key.
  2. In the scrollable log window above, all commands you have entered are displayed, together with information if the command could be carried out, and with according error messages if not. The Scripting Console lists all commands you enter for design creation (via GUI options, key strokes, or in Tcl/Python).

    Commands you entered are marked by a preceding “>”.

    Errors are highlighted in red.

    VA Tcl Console Error

  3. Use the Scripting Console to get information about commands and their syntax: Just carry out the action (you want to define in your script) using the GUI options of VisualApplets (clicking, Drag&Drop, key strokes …) and read in the log window of the Scripting Console how this action is defined in Tcl or Python. You can use Copy&Paste to copy commands into your script.

  4. Use the Scripting Console to test the commands you want to enter into your script: Just enter the command in the command input field and check if the desired action is carried out by VisualApplets. You can use Copy&Paste to copy a successful command into your script.

Info

The Scripting Console lists commands you enter for design creation: Not only commands you enter in Tcl/Python, but also commands you give by using the VisualApplets GUI options. This is very helpful when you start using scripts for VA designs, as you can easily get information about the correct commands and the according command syntax.

For a complete list of all VisualApplets-specific Tcl and Python commands, refer to the topics Tcl Command Reference and Python Command Reference.

Starting Scripts from the Scripting Console#

You have three options to start a script from the Scripting Console.

Info

Make sure the correct scripting language is selected in the Script Interpreter drop-down list box before importing the script.

Starting Scripts via the Toolbar#

You can start a script via the toolbar button Open Script:

Opening Scripts in the Scripting Console via Toolbar

Navigate to the directory where your script is located and select it.

Info

Make sure the correct scripting language is selected in the Script Interpreter drop-down list box before importing the script.

Starting Scripts Manually#

You can also type the Source command manually:

Tcl Syntax:

  1. Type the command Source into the command input field.
  2. Leave a space and type the path to the scripting file and the name of the scripting file directly after the command Source. If path or file name contain spaces, put path + file name into double quotes.
  3. Strike the Return key to start executing the script in VisualApplets.

Python Syntax:

  1. Type the command Source into the command input field.
  2. Open a parenthesis and quotation marks and type the path to the scripting file and the name of the scripting file directly after the parenthesis and quotation marks. If path or file name contain spaces, put path + file name into double quotes. Close the quotation marks and parenthesis.

    Example: Source("C:/Basler/MyPythonScript.py")

  3. Strike the Return key to start executing the script in VisualApplets.

    Opening Scripts in the Scripting Console

Copying Scripting Code into the Console#

You can also simply copy Tcl or Python code from the clipboard into the command input field:

  1. Mark the code you want to execute in your script and copy it to the clipboard.
  2. Past the code from the clipboard into the command input field.
  3. Strike the Return key to start executing the code in VisualApplets.

Quick Command Syntax Information#

To get information about the syntax of a command very quickly:

  1. Enter the name of the command into the command input field, followed by:
    • For Tcl: <CommandName> followed by a space and a question mark
    • For Python: help(<CommandName>)
  2. Press Enter.

The syntax of the parameter is displayed in the Scripting Console window.

Tcl Example:

Enter GetModules ? to get syntax information for command GetModules.

The Scripting Console window displays the required information:

Tcl Command Info

Python Example:

Enter help(GetModules) to get syntax information for command GetModules.

The Scripting Console window displays the required information:

Python Command Info

For detailed information about individual parameters and allowed values, refer to topics TCL Command Reference and Python Command Reference.