Vizard's autocomplete system helps you write code by providing completion options as you type in the editor. Relevant options will appear in a pop-up list based on context. In the image below, all viz functions and variables are initially displayed after typing "viz." then narrowed down to viz.addChild with a few more keystrokes:
The autocomplete system makes programming in Vizard more efficient by:
Reducing the need to refer to Vizard or Python documentation to remember keywords or module, class, function, and variable names.
Making it easier to enter longer words and words with mixed cases . This applies not only to existing Vizard and Python code but with your own definitions. You can re-enter longer variable names without much effort (e.g. myDescriptiveVariable) to make your code more readable.
The following table shows the types of options that autocomplete supports:
Option types |
Description |
Keywords |
All keywords available in the Python language |
Modules |
Available after an import or from statement |
Classes, functions, and variables within modules |
Available after typing <module name>. |
Methods and data attributes within objects |
Available after typing <object name>. |
Classes, functions, and variables within the current file |
Any relevant location within the file. |
The legend below defines the icons that appears in the autocomplete window:
Variable
Python keyword
Module
Function or method
Class
If a function has multiple return types, the autocomplete parser cannot be sure which type to use on the returned object. A common example of this is with the viz.add command:
Since the return type of the function above can vary, the parser is not able to determine that box is a <node3D> object. This results in incorrect completion options after typing "box.".
To correct for this, use the explicit add commands (e.g. viz.addAvatar,viz.addChild, viz.addTexQuad) which only have one return type rather than viz.add. For example, to get the correct options on a <node3D> object use viz.addChild:
A function doc string is an optional comment enclosed in triple quotes that immediately follows a function definition. It is used for documenting a function and can be accessed at runtime using Python's help command. Many Python editors, including Vizard's, display the doc string as a tooltip when the function name is typed.
Additionally, Vizard's autocomplete system recognizes several type tags inserted within the function doc string. These help to provide the user with proper completion options on:
Objects within the function that were passed as arguments.
Any object that is assigned to the return value of the function.
The following table shows the type tags supported:
Type tag |
Description |
@args <types> |
Specifies the type of arguments passed to the function by position (comma separated). |
@arg <name> <type> |
Specifies the type of an argument passed to the function by name. |
@return <type> |
Specifies the function's return type. |
Copy the following code into a new Vizard file. The @args tag specifies that the first argument will be a list and the second a dictionary. The @return tag specifies that the return type is a list.
Type in the following lines of code within the function (same level of indentation). After entering "a." and "b." you should see all list and dictionary methods, respectively, displayed in the autocomplete window. This demonstrates autocompletion on objects passed to the function as arguments:
Now type in the following code that calls the function and sorts the new list. Notice after entering "my_new_list." that all list methods are displayed in the autocomplete window. This demonstrates autocompletion on the object assigned to the return value of the function:
In the previous example the types of the arguments were specified by position. Argument types can also be specified individually by name using the @arg tag. The @arg tag in the following code specifies that argument "c" is a string. Typing this in, you should see all string options appear in the autocomplete window after entering "c." within the function: