UI Class

From Derivative
Jump to navigation Jump to search

The UI class describes access to the UI elements of the application, found in the automatically imported td module.

To access members and methods of this class use the default instance ui.

For Example:

# open the Midi Device Mapper Dialog
ui.openMIDIDeviceMapper()


Members

clipboardstr :

Get or set the operating system clipboard text contents.

colorstd.Colors (Read Only):

Access to the application colors.

dpiBiCubicFilterbool :

Get or set the global DPI scale filtering mode of TouchDesigner windows. True means bi-cubic, False means linear.

masterVolumefloat :

Get or set the master audio output volume. A value of 0 is no output, while a value of 1 is full output.

optionstd.Options (Read Only):

Access to the application options.

panestd.Panes (Read Only):

Access to the set of all panes.

performModebool :

Get or set Perform Mode. Set to True to go into Perform Mode, False to go into Designer Mode.

preferencestd.Preferences (Read Only):

Access to the application preferences, which can also be access through the Preferences Dialog.

redrawMainWindowbool :

Get or set whether the main window should redraw. The main window is either the main network editor, or the perform window.

rolloverOpOP (Read Only):

Operator currently under the mouse in a network editor.

rolloverPartd.Par (Read Only):

Parameter currently under the mouse in a parameter dialog.

rolloverPanelpanelCOMP (Read Only):

returns the latest panel to get a rollover event. Takes into account click through, depth order, and other panel settings.

lastChopChannelSelectedtd.Par (Read Only):

Last CHOP channel selected via mouse.

showPaletteBrowserbool :

Get or set display of the palette browser.

statusstr :

Get or set the status message.

ui.status = 'Operation Complete'

undotd.Undo (Read Only):

Acess to application undo functions.

windowWidthint (Read Only):

Get the app window width.

windowHeightint (Read Only):

Get the app window height.

windowXint (Read Only):

Get the app window X position.

windowYint (Read Only):

Get the app window Y position.

Methods

copyOPs(listOfOPs)None:

Copy a list of operators to the operator clipboard. All operators must be children of the same component.

  • listOfOPs - A list containing one or more OPs to be copied.
ui.copyOPs( op('geo1').selected )

pasteOPs(COMP, x=None, y=None)None:

Copy the contents of the operator clipboard into the specified component.

  • COMP - The destination to receive the operators.
  • x - Optional network coordinates at which to paste the operators.
  • y - see x
l = ui.pasteOPs( op('geo2') )

messageBox(title, message, buttons=['Ok'])int:

This method will open a message dialog box with the specified message. Returns the index of the button clicked.

  • title - Specifies the window title.
  • message - Specifies the content of the dialog.
  • buttons - (Keyword, Optional) Specifies a list button labels to show in the dialog.
# basic usage
ui.messageBox('Warning', 'Have a nice day.')
# specify options and report result
a = ui.messageBox('Please select:', 'Buttons:', buttons=['a', 'b', 'c'])
ui.messageBox('Results', 'You selected item: ' + str(a))
# pick a node from their paths
ui.messageBox('Please select:', 'Nodes:', buttons=parent().children)
# pick a node from their first names (list comprehension)
ui.messageBox('Please select:', 'Nodes:', buttons=[x.name for x in parent().children])
# pick a cell
ui.messageBox('Please select:', 'Cells:', buttons=op('table1').cells('*','*'))

refresh()None:

Update and redraw all viewports, nodes, UI elements etc immediately. This update is otherwise done once per frame at the end of all script executions. For example, if the current frame is manually changed during a script, a call to refresh will cause all dependent data to update immediately.

for i in range(100):
	ui.status = str(i)
	ui.refresh()

chooseFile(load=True, start=None, fileTypes=None, title=None, asExpression=False)str or None:

Open a dialog box for loading or saving a file. Returns the filename selected or None if the dialog is cancelled.

  • load - (Keyword, Optional) If set to True, the dialog will be a Load dialog, otherwise it's a Save dialog.
  • start - (Keyword, Optional) If provided, specifies an initial folder location and/or filename selection.
  • fileTypes - (Keyword, Optional) If provided, specifies a list of file extensions that can be used as filters. Otherwise '*.*' is the only filter.
  • asExpression - (Keyword, Optional) If set to true, the results are provided as an expression, suitable for a Parameter expression or as input to an eval() call. App Class member constants such as samplesFolder may be included in the result.
  • title (Keyword, Optional) If provided, will override the default window title.
a = ui.chooseFile(start='python_examples.toe', fileTypes=['toe'], title='Select a toe') # specify extension
a = ui.chooseFile(fileTypes=tdu.fileTypes['image'], title='Select an image') # any support image extension
path = ui.chooseFile(load=False,fileTypes=['txt'],title='Save table as:')
if (path):
	op('table1').save(path)

chooseFolder(title='Select Folder', start=None, asExpression=False)str or None:

Open a dialog box for selecting a folder. Returns the folder selected or None if the dialog is cancelled.

  • title - (Keyword, Optional) If provided, specifies the window title.
  • start - (Keyword, Optional) If provided, specifies an initial folder location and/or filename selection.
  • asExpression - (Keyword, Optional) If set to true, the results are provided as an expression, suitable for a Parameter expression or as input to an eval() call. App Class member constants such as samplesFolder may be included in the result.
a = ui.chooseFolder()
a = ui.chooseFolder(title='Select a folder location.')

viewFile(URL_or_path, showInFolder=False)None:

View a URL or file in the default external application. You can use ui.viewFile() to open a folder/directory in Windows Explorer or macOS Finder.

  • URL_or_path - URL or path to launch.
a = ui.viewFile('output.txt')
  • showInFolder - Show file as selected in Explorer or macOS Finder instead of launching an external application.
a = ui.viewFile('output.txt', showInFolder=True)

openBeat()None:

Open the Beat Dialog.

openBookmarks()None:

Open the Bookmarks Dialog.

openCOMPEditor(path)None:

Open component editor for the specific operator.

  • path - Specifies the path to the operator. An OP can be passed in as well.

openConsole()None:

Open the Console Window.

openDialogHelp(title)None:

Open help page for the specific dialog.

  • title - Specifies the help page to open.
ui.openDialogHelp('Window Placement Dialog')

openErrors()None:

Open the Errors Dialog.

openExplorer()None:

Open an Explorer window.

openExportMovie(path)None:

Open the Export Movie Dialog.

  • path - Specifies the operator content to export, optional.
ui.openExportMovie('/project1/out1')

openImportFile()None:

Open the Import File Dialog.

openKeyManager()None:

Open the Key Manager Dialog.

openMIDIDeviceMapper()None:

Open the MIDI Device Mapper Dialog.

openNewProject()None:

Open the New Project Dialog.

openOperatorSnippets(family=None, type=None, example=None)None:

Open the Operator Snippets window.

openPaletteBrowser()None:

Open the Palette.

openPerformanceMonitor()None:

Open the Performance Monitor Dialog.

openPreferences()None:

Open the Preferences Dialog.

openSearch()None:

Open the Search Replace Dialog.

openTextport()None:

Open the Textport.

openVersion()None:

Open a dialog displaying current version information. See also: App.version

openWindowPlacement()None:

Open the Window Placement Dialog.

findEditDAT(filename)DAT or None:

Given an external filename, finds the corresponding DAT thats update from this filename if any..

TouchDesigner Build: