Skip to main content
Version: 8.1

system.nav.swapTo

This function is used in Python Scripting.

Description​

Performs a window swap from the current main screen window to the window specified. Swapping means that the opened window will take the place of the closing window - in this case it will be maximized. See also: Navigation Strategies.

This function works like system.nav.swapWindow, except that you cannot specify the source for the swap.

Client Permission Restrictions​

This scripting function has no Client Permission restrictions.

Syntax​

system.nav.swapTo(path, [params])

Parameters​

TypeParameterDescription
StringpathThe path of a window to swap to.
Dictionary[String, Any]paramsA dictionary of parameters to pass into the window. The keys in the dictionary must match dynamic property names on the target window's root container. The values for each key will be used to set those properties. [optional]

Returns​

Window - A reference to window that was navigated to. Refer to the list of window objects.

Scope​

Vision Client

Code Examples​

Example #1
# This code would go in a button's ActionPerformed event to swap out of the current window and into a window named MyWindow
system.nav.swapTo("MyWindow")
Example #2
# This code would go in a button's ActionPerformed event to swap out of the current window and into a window named MyWindow. 
# It also looks at the selected value in a dropdown menu and passes that value into the new window.

# MyWindow's Root Container must have a dynamic property named "paramValue"
dropdown = event.source.parent.getComponent("Dropdown")
system.nav.swapTo("MyWindow", {"paramValue":dropdown.selectedValue})
Example #3
#This code cycles through a dictionary of windows. This could be placed on a Client Event Timer Script to cycle through some windows.
#The below code assumes that each of the windows are in the same folder (named "Main Windows")
#If the windows are in different folders, then the script would need to be modified to prepend the correct folder name on the last line of code.


#Build a dictionary of window names without directories.
windowDict = {"Overview":"Motors", "Motors":"Alarming", "Alarming":"Scripting", "Scripting":"Overview"}
#Find the current window
currentWin = system.nav.getCurrentWindow()
winObj = system.gui.getWindow(currentWin)
#Find the next window in the dictionary based on the name of the current window (winObj)
nextWindow = windowDict[winObj.name]
#Swap to the next window
system.nav.swapTo("Main Windows/" + nextWindow)