Skip to content

Python Support

ThomasPRZilliox edited this page Mar 16, 2025 · 7 revisions

2.x

The framework supports access to:

  • The Front Most VI, i.e. the User Interface (controls and indicators) of the front most window
  • A SubPanel VI, i.e. the VI loaded in a subpanel within the front most VI
  • A SubSubPanel VI, i.e. the VI loaded in a subpanel within the subpanel VI

The methods to access these three categories are encapsulated in the following packages

import lv_ui_testing.front_most_vi as fmv
import lv_ui_testing.sub_panel as sp
import lv_ui_testing.sub_sub_panel as ssp

Methods

Front Most VI specific

Methods Description
click_on_close Press the close (red cross) button of the window

Shared

The following methods can be called by the three packages; however, their arguments might differ. For example:

# Get the VI name of the front most window
front_most_vi = fmv.get_vi_name()

# Get the VI name of the subpanel called "Sub Panel" (This subpanel should be in the front most window)
sp_vi = sp.get_vi_name("Sub Panel")

# Get the VI name of the subpanel called "Sub Panel Children" which is contained in another subpanel called
# "Sub Panel"  (This subpanel should be in the front most window)
ssp_vi = ssp.get_vi_name("Sub Panel","Sub Panel Children") 
Methods Description
click_on_button Click on a boolean control
get_control_details Get the Caption, Label visibility and Control visibility of all controls
get_cluster_details Get the Caption, Label visibility and Control visibility of all controls within a cluster
get_value_xml Return the XML of a control, recommended way to read a cluster
get_vi_name Get the VI name (of the front most window or loaded in a specific subpanel)
resolve_value Return the value of a control and parse it to its type for python, for example it will return an U32 if the control is of that type (support Numeric, String, Boolean and Array (of the previous types) controls and indicators)
set_cluster_elem Set an element of a cluster
set_value_ARR_STR Set a string array control (for example, a tree control)
set_value_BOOL Set a boolean control (It will not work if it has a latch mechanism !!)
set_value_DBL Set a numeric control
set_value_STR Set a string control

Legacy from 1.x

Prefer the method resolve_value than the following methods:

Methods Description
get_value Return the value of the "Anything to string of a specific control"
get_value_TREE Return the value of a tree control
get_value_DBL Return the value of a float control
get_value_bool Return the value of a bool control

1.x

To import the package start your script with the following line:

from lv_ui_testing import ui_testing

The methods are split into two categories:

  • FMV : the one for the Front Most Vi
  • SP : the one for a VI inside a SubPanel of the front most Vi

The arguments of the different methods are often similar:

  • control_label : the label of the control/indicator
  • subpanel_label : the label of the subpanel object

Front Most Vi

FMV_get_vi_name()

Returns the name of the front most VI.

FMV_click_on_button(control_label)

Simulate the click of a User on a button (boolean).

FMV_get_value(control_label)

Returns the current value of a control/indicator as a string.

FMV_get_value_DBL(control_label)

Returns the current value of a control/indicator as a number.

FMV_get_value_bool(control_label)

Returns the current value of a control/indicator as a bool.

FMV_set_value_DBL(control_label,number)

Set a number (double format) to a control.

Subpanel

SP_get_vi_name(subpanel_label)

Returns the name of the VI inside the subpanel object.

SP_click_on_button(subpanel_label,control_label)

Simulate the click of a User on a button (boolean) in the VI inside the subpanel object.

SP_get_value(subpanel_label,control_label)

Returns the current value as a string of a control/indicator in the VI inside the subpanel object.

SP_get_value_DBL(subpanel_label,control_label)

Returns the current value as a number of a control/indicator in the VI inside the subpanel object.

SP_get_value_bool(subpanel_label,control_label)

Returns the current value as a boolean of a control/indicator in the VI inside the subpanel object.

SP_set_value_DBL(subpanel_label,control_label)

Set a number (double format) to a control/indicator in the VI inside the subpanel object.