Difference between revisions of "UI Class"

From TouchDesigner Documentation
Jump to: navigation, search
(UI Class Auto Create)
 
m
 
(22 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{lowercase}}
+
{{TDClassSummary|label=UI|summary=The UI class describes access to the UI elements of the application, found in the automatically imported [[td Module|td module]].
{{TDClassSummary|summary=The UI class describes access to the UI elements of the application, found in the automatically imported td module.}}
+
 
{{ClassMemberSection|empty=}}
+
To access members and methods of this class use the default instance <code>ui</code>.
 +
 
 +
For Example:
 +
<syntaxhighlight lang=python>
 +
# open the Midi Device Mapper Dialog
 +
ui.openMIDIDeviceMapper()
 +
</syntaxhighlight>}}
 +
<section begin=HELPBODY />
 +
{{ClassMemberSection|empty=
 +
|Sectionsummary=
 +
|items=
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=clipboard
 
     |name=clipboard
     |returns=
+
     |type=str
     |set=0
+
     |set=1
 
     |text=Get or set the operating system clipboard text contents.
 
     |text=Get or set the operating system clipboard text contents.
 
}}
 
}}
Line 12: Line 22:
 
     |class=UI
 
     |class=UI
 
     |name=colors
 
     |name=colors
     |returns=
+
     |type=td.Colors
 
     |set=0
 
     |set=0
     |text=Access to the application colors.
+
     |text=Access to the application [[Colors Class|colors]].}}
}}
 
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=dpiBiCubicFilter
 
     |name=dpiBiCubicFilter
     |returns=
+
     |type=bool
     |set=0
+
     |set=1
 
     |text=Get or set the global DPI scale filtering mode of TouchDesigner windows. True means bi-cubic, False means linear.
 
     |text=Get or set the global DPI scale filtering mode of TouchDesigner windows. True means bi-cubic, False means linear.
 
}}
 
}}
Line 26: Line 35:
 
     |class=UI
 
     |class=UI
 
     |name=masterVolume
 
     |name=masterVolume
     |returns=
+
     |type=float
     |set=0
+
     |set=1
 
     |text=Get or set the master audio output volume. A value of 0 is no output, while a value of 1 is full output.
 
     |text=Get or set the master audio output volume. A value of 0 is no output, while a value of 1 is full output.
 
}}
 
}}
Line 33: Line 42:
 
     |class=UI
 
     |class=UI
 
     |name=options
 
     |name=options
     |returns=
+
     |type=td.Options
 
     |set=0
 
     |set=0
     |text=Access to the application options.
+
     |text=Access to the application [[Options Class|options]].}}
}}
 
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=panes
 
     |name=panes
     |returns=
+
     |type=td.Panes
 
     |set=0
 
     |set=0
     |text=Access to the set of all panes.
+
     |text=Access to the set of all [[Panes Class|panes]].}}
}}
 
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=performMode
 
     |name=performMode
     |returns=
+
     |type=bool
     |set=0
+
     |set=1
     |text=Get or set Perform Mode.  Set to True to go into Perform Mode, False to go into Designer Mode.
+
     |text=Get or set [[Perform Mode]].  Set to True to go into Perform Mode, False to go into [[Designer Mode]].}}
}}
 
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=preferences
 
     |name=preferences
     |returns=
+
     |type=td.Preferences
 
     |set=0
 
     |set=0
     |text=Access to the application preferences, which can also be access through the Preferences Dialog.
+
     |text=Access to the application [[Preferences Class|preferences]], which can also be access through the [[Preferences Dialog]].}}
}}
 
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=redrawMainWindow
 
     |name=redrawMainWindow
     |returns=
+
     |type=bool
     |set=0
+
     |set=1
 
     |text=Get or set whether the main window should redraw. The main window is either the main network editor, or the perform window.
 
     |text=Get or set whether the main window should redraw. The main window is either the main network editor, or the perform window.
 
}}
 
}}
Line 68: Line 73:
 
     |class=UI
 
     |class=UI
 
     |name=rolloverOp
 
     |name=rolloverOp
     |returns=
+
     |type=OP
 
     |set=0
 
     |set=0
     |text=Node currently under the mouse in the network editor.
+
     |text=Operator currently under the mouse in a network editor.
 
}}
 
}}
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=rolloverPar
 
     |name=rolloverPar
     |returns=
+
     |type=td.Par
 
     |set=0
 
     |set=0
     |text=Parameter currently under the mouse a parameter dialog.
+
     |text=Parameter currently under the mouse in a parameter dialog.
 
}}
 
}}
 +
{{ClassMember
 +
    |class=UI
 +
    |name=lastChopChannelSelected
 +
    |type=td.Par
 +
    |set=0
 +
    |text=Last [[Channel|CHOP channel]] selected via mouse.}}
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=showPaletteBrowser
 
     |name=showPaletteBrowser
     |returns=
+
     |type=bool
     |set=0
+
     |set=1
 
     |text=Get or set display of the palette browser.
 
     |text=Get or set display of the palette browser.
 
}}
 
}}
Line 89: Line 100:
 
     |class=UI
 
     |class=UI
 
     |name=status
 
     |name=status
     |returns=
+
     |type=str
     |set=0
+
     |set=1
     |text=Get or set the status message. Example:  ui.status = 'Operation Complete'  
+
     |text=Get or set the status message.
 +
<syntaxhighlight lang=python>
 +
ui.status = 'Operation Complete'
 +
</syntaxhighlight>
 
}}
 
}}
 
{{ClassMember
 
{{ClassMember
 
     |class=UI
 
     |class=UI
 
     |name=undo
 
     |name=undo
     |returns=
+
     |type=td.Undo
 
     |set=0
 
     |set=0
 
     |text=Acess to application undo functions.
 
     |text=Acess to application undo functions.
 
}}
 
}}
{{ClassMethodSection|empty=}}
+
{{ClassMember
{{ClassMethod
 
 
     |class=UI
 
     |class=UI
     |name=openMIDIDeviceMapper
+
     |name=windowWidth
     |call=openMIDIDeviceMapper()
+
     |type=int
     |returns=
+
     |set=0
     |text=:
+
     |text=Get the app window width.
Open the MIDI Device Mapper Dialog.
 
 
}}
 
}}
{{ClassMethod
+
{{ClassMember
 
     |class=UI
 
     |class=UI
     |name=openKeyManager
+
     |name=windowHeight
     |call=openKeyManager()
+
     |type=int
     |returns=
+
     |set=0
     |text=:
+
     |text=Get the app window height.
Open the Key Manager Dialog.
 
 
}}
 
}}
{{ClassMethod
+
{{ClassMember
 
     |class=UI
 
     |class=UI
     |name=viewFile
+
     |name=windowX
     |call=viewFile(url_or_path)
+
     |type=int
     |returns=
+
     |set=0
     |text=:
+
     |text=Get the app window X position.
View a url or file in the default external application.
 
url_or_path - url or path to launch.
 
a = ui.viewFile('output.txt')
 
 
}}
 
}}
{{ClassMethod
+
{{ClassMember
 
     |class=UI
 
     |class=UI
     |name=openExplorer
+
     |name=windowY
     |call=openExplorer()
+
     |type=int
     |returns=
+
     |set=0
     |text=:
+
     |text=Get the app window Y position.
Open an Explorer window.
+
}}}}
}}
+
{{ClassMethodSection|empty=
 +
|Sectionsummary=
 +
|items=
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openPerformanceMonitor
+
     |name=copyOPs
     |call=openPerformanceMonitor()
+
     |call=copyOPs(listOfOPs)
     |returns=
+
     |returns=None
     |text=:
+
     |text=Copy a list of operators to the operator clipboard. All operators must be children of the same component.
Open the Performance Monitor Dialog.
+
*listOfOPs - A list containing one or more OPs to be copied.
}}
+
<syntaxhighlight lang=python>ui.copyOPs( op('geo1').selected )</syntaxhighlight>}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=refresh
+
     |name=pasteOPs
     |call=refresh()
+
     |call=pasteOPs(COMP, x=None, y=None)
     |returns=
+
     |returns=None
     |text=:
+
     |text=Copy the contents of the operator clipboard into the specified component.
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.
+
*COMP - The destination to receive the operators.
for i in range(100):
+
*x - Optional network coordinates at which to paste the operators.
ui.status = str(i)
+
*y - see x
ui.refresh()
+
<syntaxhighlight lang=python>l = ui.pasteOPs( op('geo2') )</syntaxhighlight>}}
}}
 
{{ClassMethod
 
    |class=UI
 
    |name=openPaletteBrowser
 
    |call=openPaletteBrowser()
 
    |returns=
 
    |text=:
 
Open the Palette.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=messageBox
 
     |name=messageBox
 
     |call=messageBox(title, message, buttons=['Ok'])
 
     |call=messageBox(title, message, buttons=['Ok'])
     |returns=
+
     |returns=int
     |text=: -> int
+
     |text=This method will open a message dialog box with the specified message.  Returns the index of the button clicked.
This method will open a message dialog box with the specified message.  Returns the index of the button clicked.
+
*title - Specifies the window title.
title - Specifies the window title.
+
*message - Specifies the content of the dialog.
message - Specifies the content of the dialog.
+
*buttons - (Keyword, Optional) Specifies a list button labels to show in the dialog.
buttons - (Keyword, Optional) Specifies a list button labels to show in the dialog.
+
<syntaxhighlight lang=python>
#basic usage
+
# basic usage
 
ui.messageBox('Warning', 'Have a nice day.')
 
ui.messageBox('Warning', 'Have a nice day.')
#specify options and report result
+
# specify options and report result
 
a = ui.messageBox('Please select:', 'Buttons:', buttons=['a', 'b', 'c'])
 
a = ui.messageBox('Please select:', 'Buttons:', buttons=['a', 'b', 'c'])
 
ui.messageBox('Results', 'You selected item: ' + str(a))
 
ui.messageBox('Results', 'You selected item: ' + str(a))
#pick a node from their paths
+
# pick a node from their paths
ui.messageBox('Please select:', 'Nodes:', buttons=me.parent().children)
+
ui.messageBox('Please select:', 'Nodes:', buttons=parent().children)
#pick a node from their first names (list comprehension)
+
# pick a node from their first names (list comprehension)
ui.messageBox('Please select:', 'Nodes:', buttons=[x.name for x in me.parent().children])
+
ui.messageBox('Please select:', 'Nodes:', buttons=[x.name for x in parent().children])
#pick a cell
+
# pick a cell
 
ui.messageBox('Please select:', 'Cells:', buttons=op('table1').cells('*','*'))
 
ui.messageBox('Please select:', 'Cells:', buttons=op('table1').cells('*','*'))
 +
</syntaxhighlight>
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openVersion
+
     |name=refresh
     |call=openVersion()
+
     |call=refresh()
     |returns=
+
     |returns=None
     |text=:
+
     |text=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.
Open a dialog displaying current version information.
+
<syntaxhighlight lang=python>
See also: App.version
+
for i in range(100):
 +
ui.status = str(i)
 +
ui.refresh()
 +
</syntaxhighlight>
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openTextport
+
     |name=chooseFile
     |call=openTextport()
+
     |call=chooseFile(load=True, start=None, fileTypes=None, title=None, asExpression=False)
     |returns=
+
     |returns=str or None
     |text=:
+
     |text=Open a dialog box for loading or saving a file.  Returns the filename selected or None if the dialog is cancelled.
Open the Textport.
+
*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 [[Par Class|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.
 +
<syntaxhighlight lang=python>
 +
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)
 +
</syntaxhighlight>}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=chooseFolder
 
     |name=chooseFolder
 
     |call=chooseFolder(title=<nowiki>'Select Folder'</nowiki>, start=None, asExpression=False)
 
     |call=chooseFolder(title=<nowiki>'Select Folder'</nowiki>, start=None, asExpression=False)
     |returns=
+
     |returns=str or None
     |text=: -> str or None
+
     |text=Open a dialog box for selecting a folder.  Returns the folder selected or None if the dialog is cancelled.
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.
title - (Keyword, Optional) If provided, specifies the window title.
+
*start - (Keyword, Optional) If provided, specifies an initial folder location and/or filename selection.
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 [[Par Class|Parameter]] expression or as input to an eval() call.  [[App Class]] member constants such as samplesFolder may be included in the result.
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.
+
<syntaxhighlight lang=python>
 
a = ui.chooseFolder()
 
a = ui.chooseFolder()
 
a = ui.chooseFolder(title='Select a folder location.')
 
a = ui.chooseFolder(title='Select a folder location.')
 +
</syntaxhighlight>}}
 +
{{ClassMethod
 +
    |class=UI
 +
    |name=viewFile
 +
    |call=viewFile(url_or_path)
 +
    |returns=None
 +
    |text=View a url or file in the default external application.
 +
*url_or_path - url or path to launch.
 +
<syntaxhighlight lang=python>
 +
a = ui.viewFile('output.txt')
 +
</syntaxhighlight>
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openPreferences
+
     |name=openAbletonControl
     |call=openPreferences()
+
     |call=openAbletonControl()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Deprecated. Use [[TDAbleton]] instead.}}
Open the Preferences Dialog.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=openBeat
 
     |name=openBeat
 
     |call=openBeat()
 
     |call=openBeat()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Beat Dialog]].}}
Open the Beat Dialog.
+
{{ClassMethod
 +
    |class=UI
 +
    |name=openBookmarks
 +
    |call=openBookmarks()
 +
    |returns=None
 +
    |text=Open the [[Bookmarks Dialog]].}}
 +
{{ClassMethod
 +
    |class=UI
 +
    |name=openCOMPEditor
 +
    |call=openCOMPEditor(path)
 +
    |returns=None
 +
    |text=Open component editor for the specific operator.
 +
*path - Specifies the path to the operator.  An OP can be passed in as well.
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openAbletonControl
+
     |name=openConsole
     |call=openAbletonControl()
+
     |call=openConsole()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Console Window]].}}
Open dialog to the Ableton controller.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=openDialogHelp
 
     |name=openDialogHelp
 
     |call=openDialogHelp(title)
 
     |call=openDialogHelp(title)
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open help page for the specific dialog.
Open help page for the specific dialog.
+
*title - Specifies the help page to open.
title - Specifies the help page to open.
+
<syntaxhighlight lang=python>
 
ui.openDialogHelp('Window Placement Dialog')
 
ui.openDialogHelp('Window Placement Dialog')
 +
</syntaxhighlight>
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openImportFile
+
     |name=openErrors
     |call=openImportFile()
+
     |call=openErrors()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Errors Dialog]].}}
Open the Import File Dialog.
+
{{ClassMethod
 +
    |class=UI
 +
    |name=openExplorer
 +
    |call=openExplorer()
 +
    |returns=None
 +
    |text=Open an Explorer window.
 
}}
 
}}
 +
{{ClassMethod
 +
    |class=UI
 +
    |name=openExportMovie
 +
    |call=openExportMovie(path="")
 +
    |returns=None
 +
    |text=Open the [[Export Movie Dialog]].
 +
*path - Specifies the operator content to export.}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=openHelp
 
     |name=openHelp
 
     |call=openHelp()
 
     |call=openHelp()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Commands_and_Expressions|Help Dialog]].}}
Open the Help Dialog.
+
{{ClassMethod
}}
+
    |class=UI
 +
    |name=openImportFile
 +
    |call=openImportFile()
 +
    |returns=None
 +
    |text=Open the [[Import File Dialog]].}}
 +
{{ClassMethod
 +
    |class=UI
 +
    |name=openKeyManager
 +
    |call=openKeyManager()
 +
    |returns=None
 +
    |text=Open the [[Key Manager Dialog]].}}
 +
{{ClassMethod
 +
    |class=UI
 +
    |name=openMIDIDeviceMapper
 +
    |call=openMIDIDeviceMapper()
 +
    |returns=None
 +
    |text=Open the [[MIDI Device Mapper Dialog]].}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openConsole
+
     |name=openNewProject
     |call=openConsole()
+
     |call=openNewProject()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[New Project Dialog]].}}
Open the Console Window.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openErrors
+
     |name=openOperatorSnippets
     |call=openErrors()
+
     |call=openOperatorSnippets(family=None, type=None, example=None)
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the Operator Snippets window.}}
Open the Errors Dialog.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openBookmarks
+
     |name=openPaletteBrowser
     |call=openBookmarks()
+
     |call=openPaletteBrowser()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Palette]].}}
Open the Bookmarks Dialog.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=chooseFile
+
     |name=openPerformanceMonitor
     |call=chooseFile(load=True, start=None, fileTypes=None, title=None, asExpression=False)
+
     |call=openPerformanceMonitor()
     |returns=
+
     |returns=None
     |text=: -> str or None
+
     |text=Open the [[Performance Monitor Dialog]].}}
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);
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openWindowPlacement
+
     |name=openPreferences
     |call=openWindowPlacement()
+
     |call=openPreferences()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Preferences Dialog]].}}
Open the Window Placement Dialog.
 
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
 
     |name=openSearch
 
     |name=openSearch
 
     |call=openSearch()
 
     |call=openSearch()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Search Dialog]].}}
Open the Search Dialog.
+
{{ClassMethod
}}
+
    |class=UI
 +
    |name=openTextport
 +
    |call=openTextport()
 +
    |returns=None
 +
    |text=Open the [[Textport]].}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openNewProject
+
     |name=openVersion
     |call=openNewProject()
+
     |call=openVersion()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open a dialog displaying current version information.
Open the New Project Dialog.
+
See also: [[App Class|App.version]]}}
}}
 
 
{{ClassMethod
 
{{ClassMethod
 
     |class=UI
 
     |class=UI
     |name=openExportMovie
+
     |name=openWindowPlacement
     |call=openExportMovie(path="")
+
     |call=openWindowPlacement()
     |returns=
+
     |returns=None
     |text=:
+
     |text=Open the [[Window Placement Dialog]].}}}}
Open the Export Movie Dialog.
+
<section end=HELPBODY />
path - Specifies the operator content to export.
+
{{History}}
}}
+
{{#invoke:Category|list|Python Reference}}
<taggedhistory/>
 
 
 
{{{{#invoke:Category|list|Python Reference}}}}
 

Latest revision as of 16:32, 8 May 2020

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[edit]

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.

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[edit]

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)None:

View a url or file in the default external application.

  • url_or_path - url or path to launch.
a = ui.viewFile('output.txt')

openAbletonControl()None:

Deprecated. Use TDAbleton instead.

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.

openHelp()None:

Open the Help Dialog.

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 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.

TouchDesigner Build:

Any floating window that is not a Pane or Viewer.

Mode where the network editing window is not open, your performance interface window(s) is open and you are running your application as fast as possible. See Designer Mode.

Any of the procedural data operators. OPs do all the work in TouchDesigner. They "cook" and output data to other OPs, which ultimately result in new images, data and audio being generated. See Node.

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

TOuch Environment file, the file type used by TouchDesigner to save your project.

The operating system's holder of files and other folders (directories). It does not refer to operators within TouchDesigner. See Network Path.

Strictly refers to a window in Microsoft Windows. User-created windows are made with Panels inside Window Components, aside from the TouchDesigner editor window and its dialogs.

OP Snippets is a set of numerous examples of TouchDesigner operators, which you access via the Help menu. These can be copied/pasted into your projects.