Intel® Quartus® Prime Standard Edition User Guide: Debug Tools

ID 683552
Date 9/24/2018
Public
Document Table of Contents

2.9.6.2. Toolkit API Script Examples

Making the Toolkit Visible in System Console

Use the toolkit_set_property command to modify the visible property of the root toolkit. Use the word self if a property is applied to the entire toolkit. In other cases, refer to the root toolkit using all.

toolkit_set_property self visible true

Adding Widgets

Use the toolkit_add command to add widgets.

toolkit_add my_button button all

The following commands add a label widget my_label to the root toolkit. In the GUI, the label appears as Widget Label.

set name "my_label"
set content "Widget Label"
toolkit_add $name label all
toolkit_set_property $name text $content

In the GUI, the displayed text changes to the new value. Add one more label:

toolkit_add my_label_2 label all
toolkit_set_property my_label_2 text "Another label"

The new label appears to the right of the first label.

To place the new label under the first, use the following command:

toolkit_set_property self itemsPerRow 1

Gathering Input

To incorporate user input into your Toolkit API,

  1. Create a text field using the following commands:
    set name "my_text_field"
    set widget_type "textField"
    set parent "all"
    toolkit_add $name $widget_type $parent
  2. The widget size is very small. To make the widget fill the horizontal space, use the following command:
    toolkit_set_property my_text_field expandableX true
  3. Now, the text field is fully visible. You can type text into the field, on clicking. To retrieve the contents of the field, use the following command:
    set content [toolkit_get_property my_text_field text]
    puts $content

This command prints the contents into the console.

Updating Widgets Upon User Events

When you use callbacks, the Toolkit API can also perform actions without interactive typing:

  1. Start by defining a procedure that updates the first label with the text field contents:
    proc update_my_label_with_my_text_field{
        set content [toolkit_get_property my_text_field text]
        toolkit_set_property my_label text $content
    }
  2. Run the update_my_label_with_my_text_field command in the Tcl Console. The first label now matches the text field contents.
  3. Use the update_my_label_with_my_text_field command whenever the text field changes:
    toolkit_set_property my_text_field onChange update_my_label_with_my_text_field

    The Toolkit executes the onChange property each time the text field changes. The execution of this property changes the first field to match what you type.

Buttons

Use buttons to trigger actions.

  1. To create a button that changes the second label:
    proc append_to_my_label_2 {suffix} {
    						set old_text [toolkit_get_property my_label_2 text]
    						set new_text "${old_text}${suffix}"
    						toolkit_set_property my_label_2 text $new_text
    						}
    						set text_to_append ", and more"
    						toolkit_add my_button button all
    						toolkit_set_property my_button onClick [append_to_my_label_2 $text_to_append]
  2. Click the button to append some text to the second label.

Groups

The property itemsPerRow dictates the laying out of widgets in a group. For more complicated layouts where the number of widgets per row is different, use nested groups. To add a new group with more widgets per row:

toolkit_add my_inner_group group all
toolkit_set_property my_inner_group itemsPerRow 2
toolkit_add inner_button_1 button my_inner_group
toolkit_add inner_button_2 button my_inner_group

These commands create a row with a group of two buttons. To make the nested group more seamless, remove the border with the group name using the following commands:

toolkit_set_property my_inner_group title ""

You can set the title property to any other string to ensure the display of the border and title text.

Tabs

Use tabs to manage widget visibility:

toolkit_add my_tabs tabbedGroup all
toolkit_set_property my_tabs expandableX true
toolkit_add my_tab_1 group my_tabs
toolkit_add my_tab_2 group my_tabs
toolkit_add tabbed_label_1 label my_tab_1
toolkit_add tabbed_label_2 label my_tab_2
toolkit_set_property tabbed_label_1 text "in the first tab"
toolkit_set_property tabbed_label_2 text "in the second tab"

These commands add a set of two tabs, each with a group containing a label. Clicking on the tabs changes the displayed group/label.