pymel.core.system.displayString

displayString(*args, **kwargs)

Assign a string value to a string identifier. Allows you define a string in one location and then refer to it by its identifier in many other locations. Formatted strings are also supported (NOTE however, this functionality is now provided in a more general fashion by the format command, use of format is recommended). You may embed up to 3 special character sequences ^1s, ^2s, and ^3s to perform automatic string replacement. The embedded characters will be replaced with the extra command arguments. See example section for more detail. Note the extra command arguments do not need to be display string identifiers. In query mode, return type is based on queried flag.

Flags:
Long name (short name) Argument Types Properties
delete (d) bool ../../../_images/create.gif
 
This flag is used to remove an identifer string. The command will fail if the identifier does not exist.
exists (ex) bool ../../../_images/create.gif
 
Returns true or false depending upon whether the specified identifier exists.
keys (k) bool ../../../_images/create.gif ../../../_images/query.gif
 

List all displayString keys that match the identifier string. The identifier string may be a whole or partial key string. The command will return a list of all identifier keys that contain this identifier string as a substring.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

replace (r) bool ../../../_images/create.gif ../../../_images/query.gif
 

Since a displayString command will fail if it tries to assign a new value to an existing identifer, this flag is required to allow updates to the value of an already-existing identifier. If the identifier does not already exist, a new identifier is added as if the -replace flag were not present.

value (v) unicode ../../../_images/create.gif ../../../_images/query.gif
 
The display string’s value. If you do not specify this flag when creating a display string then the value will be the same as the identifier.

Derived from mel command maya.cmds.displayString

Example:

import pymel.core as pm

#    Associate a string with an identifier.
#
pm.displayString( 'kExampleHelloWorld', value='Hello world' )
#    Query string associated with an identifer.
#
pm.displayString( 'kExampleHelloWorld', query=True, value=True )
#    Define a simple formatted string to append ellipses.
#
pm.displayString( 'kExampleEllipsesFormat', value='^1s...' )
pm.displayString( 'kExampleEllipsesFormat', 'kExampleHelloWorld', query=True, value=True )
#    Define a formatted string using all the available
#    embedded characters.
#
pm.displayString( 'kExampleAnotherFormat', value='These ^1s are ^2s me ^3s' )
pm.displayString( 'kExamplePretzels', value='pretzels' )
pm.displayString( 'kExampleAnotherFormat', 'kExamplePretzels', 'making', 'thirsty', query=True, value=True )
# Obtain a list of matching displayString keys.
# In the first example  a list of  all keys containing the substring
# "niceName".
# In the second example a list of all keys in the string set
# m_testStrings
pm.displayString( 'niceName', query=True, keys=True )
pm.displayString( 'm_testStrings.', query=True, keys=True )
#    If you do not specify the -v/value flag on creating then
#    the value will be the same as the identifier.
#
pm.displayString( 'kExampleMissingValue' )
pm.displayString( 'kExampleMissingValue', query=True, value=True )

Previous topic

pymel.core.system.displayInfo

Next topic

pymel.core.system.displayWarning

Core

Core Modules

Other Modules

This Page