UI Class

From TouchDesigner 099 Wiki

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

Members

clipboard Get or set the operating system clipboard text contents.
colors (Read Only) Access to the application colors.
dpiBiCubicFilter Get or set the global DPI scale filtering mode of TouchDesigner windows. True means bi-cubic, False means linear.
dpiScale Get or set the global DPI scale of TouchDesigner windows. This is used to make UI larger for high DPI displays.
masterVolume Get or set the master audio output volume. A value of 0 is no output, while a value of 1 is full output.
options (Read Only) Access to the application options.
panes (Read Only) Access to the set of all panes.
performMode Get or set Perform Mode. Set to True to go into Perform Mode, False to go into Designer Mode.
preferences (Read Only) Access to the application preferences, which can also be access through the Preferences Dialog.
redrawMainWindow Get or set whether the main window should redraw. The main window is either the main network editor, or the perform window.
showPaletteBrowser Get or set display of the palette browser.
status Get or set the status message. Example: ui.status = 'Operation Complete'

Methods

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=me.parent().children)
   #pick a node from their first names (list comprehension)
   ui.messageBox('Please select:', 'Nodes:', buttons=[x.name for x in me.parent().children])
   #pick a cell
   ui.messageBox('Please select:', 'Cells:', buttons=op('table1').cells('*','*'))

refresh()

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)

View a url or file in the default external application.
  • url_or_path - url or path to launch.
   a = ui.viewFile('output.txt')

openAbletonControl()

Deprecated. Use TDAbleton instead.

openBeat()

Open the Beat Dialog.

openBookmarks()

Open the Bookmarks Dialog.

openCHOPExporter()

Open the CHOP Exporter Dialog.

openConsole()

Open the Console Window.

openDialogHelp(title)

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

openErrors()

Open the Errors Dialog.

openExplorer()

Open an Explorer window.

openExportMovie(path="")

Open the Export Movie Dialog.
  • path - Specifies the operator content to export.

openHelp()

Open the Help Dialog.

openImportFile()

Open the Import File Dialog.

openKeyManager()

Open the Key Manager Dialog.

openMIDIDeviceMapper()

Open the MIDI Device Mapper Dialog.

openNewProject()

Open the New Project Dialog.

openPaletteBrowser()

Open the Palette.

openPerformanceMonitor()

Open the Performance Monitor Dialog.

openPreferences()

Open the Preferences Dialog.

openSearch()

Open the Search Dialog.

openTextport()

Open the Textport.

openVersion()

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

openWindowPlacement()

Open the Window Placement Dialog.