pymel.core.windows.dimWhen

dimWhen(*args, **kwargs)

This method attaches the named UI object (first argument) to the named condition (second argument) so that the object will be dimmed when the condition is in a particular state. This command will fail if the object does not exist. If the condition does not exist (yet), that’s okay — a placeholder will be used until such a condition comes into existence. The UI object should be one of two things, either a control or a menu item.

Flags:
Long name (short name) Argument Types Properties
clear (c) bool ../../../_images/create.gif
 
Remove the condition on the specified dimmable.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.
false (f) bool ../../../_images/create.gif
 
Dim the object when the condition is false.
true (t) bool ../../../_images/create.gif
 
Dim the object when the condition is true. (default)

Derived from mel command maya.cmds.dimWhen

Example:

import pymel.core as pm

#    Create a window with a menu item and button that will dim if
#    there are no objects selected in the scene.
#
window = pm.window(menuBar=True, title='dimWhen Example')
pm.menu( label='Edit' )
# Result: ui.Menu('window1|menu39') #
menuItem = pm.menuItem(label='Delete Selection', command='pm.delete()')
pm.columnLayout(adjustableColumn=True)
# Result: ui.ColumnLayout('window1|columnLayout26') #
button = pm.button(label='Delete Selection', command='pm.delete()')

#    Create a few buttons to create some objects, select all the objects in
#    the scene, and clear the selection.
#
pm.button(label='Create Objects', command='pm.sphere(); pm.cone(); pm.cylinder();')
# Result: ui.Button('window1|columnLayout26|button23') #
pm.button(label='Select All', command='pm.select(all=True)')
# Result: ui.Button('window1|columnLayout26|button24') #
pm.button(label='Select Nothing', command='pm.select(clear=True)')
# Result: ui.Button('window1|columnLayout26|button25') #

#    Add the dim conditions.
#
pm.dimWhen( 'SomethingSelected', button, false=True )
pm.dimWhen( 'SomethingSelected', menuItem, false=True )

pm.showWindow( window )

Previous topic

pymel.core.windows.devicePanel

Next topic

pymel.core.windows.disable

Core

Core Modules

Other Modules

This Page