pymel.core.windows.panelHistory¶
- panelHistory(*args, **kwargs)¶
This command creates a panel history object. The object is targeted on a particular paneLayout and thereafter notes changes in panel configurations within that paneLayout, building up a history list. The list can be stepped through backwards or forwards.
Flags:
Long Name / Short Name Argument Types Properties back / b bool Go back one level on the history list. clear / cl bool Clear the history stack defineTemplate / dt unicode Puts the command in a mode where any other flags and args are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template. exists / ex bool Returns whether the specified object exists or not. Other flags are ignored. forward / f bool Go forward one level on the history list. historyDepth / hd int Specifies how many levels of history are maintained. isEmpty / ie bool Returns true if there is currently no panel history. suspend / s bool Specifies whether to suspend or resume updates to the panel history. Useful for chunking a number of changes into one history event. targetPane / tp unicode Specifies which paneLayout the history will be maintained for. useTemplate / ut unicode Forces the command to use a command template other than the current one. wrap / w bool Specifies whether the history will wrap at the end and beginning. This value is true by default. Flag can have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.panelHistory
Example:
import pymel.core as pm # Create a window containing a pane layout. The window also contains # an option menu for changing the layout configuration and two buttons # for stepping through the configuration history. # window = pm.window( title='panelHistory Example' ) form = pm.formLayout() # Create the option menu for panel configuration. # configuration = pm.optionMenuGrp( label='Configuration', columnWidth2=( 100, 150 ) ) single = pm.menuItem( label='Single' ) stacked = pm.menuItem( label='2 Stacked' ) sideBySide = pm.menuItem( label='2 Side by Side' ) four = pm.menuItem( label='Four' ) # Create the buttons for stepping through configuration history. # history = pm.rowLayout( numberOfColumns=3 , columnWidth3=( 100, 75, 75 ), columnAttach=[( 2, 'both', 0 ),( 3, 'both', 0 )] ) pm.text( label='History' ) backBtn = pm.button( label='Back' ) forwardBtn = pm.button( label='Forward' ) pm.setParent( '..' ) # Create the pane layout. # frame = pm.frameLayout( labelVisible=False ) panes = pm.paneLayout() pm.text( label='Pane 1' ) pm.text( label='Pane 2' ) pm.text( label='Pane 3' ) pm.text( label='Pane 4' ) # Set up the attachments. # pm.formLayout( form, edit=True, attachForm=[(configuration, 'top', 5), (configuration, 'left', 5), (history, 'left', 5), (history, 'right', 5), (frame, 'left', 5), (frame, 'right', 5), (frame, 'bottom', 5)], attachControl=[(history, 'top', 5, configuration), (frame, 'top', 5, history)] ) # Create the panel history object. # panelHistory = pm.panelHistory(targetPane=panes) # Attach a command to the option menu to change the panel layout # configuration accordingly. # pm.optionMenuGrp( configuration, edit=True, changeCommand=('ExampleUpdatePaneLayout( \"'+ configuration + '\", \"' + panes + '\" )') ) # Attach commands to the buttons for stepping through the configuration # history. The commands should also update the value of the option menu. # pm.button( backBtn, edit=True, command='pm.panelHistory( panelHistory, edit=True, back=True ); ExampleUpdateConfiguration( \"' + configuration + '\", \"' + panes + '\" )' ) pm.button( forwardBtn, edit=True, command='pm.panelHistory( panelHistory, edit=True, forward=True ); ExampleUpdateConfiguration( \"' + configuration + '\", \"' + panes + '\" )' ) pm.showWindow( window ) # Call this procedure whenever the option menu's configuration value # changes. This procedure will update the configuration of the # pane layout to reflect the change. # def ExampleUpdatePaneLayout( optionMenuGrp, paneLayout ): if optionMenuGrp == "" or paneLayout == "": return value = pm.optionMenuGrp( optionMenuGrp, query=True, value=True ) if value == "Single": pm.paneLayout( paneLayout, edit=True, configuration='single' ) elif value == "2 Stacked": pm.paneLayout( paneLayout, edit=True, configuration='horizontal2' ) elif value == "2 Side by Side": pm.paneLayout( paneLayout, edit=True, configuration='vertical2' ) elif value == "Four": pm.paneLayout( paneLayout, edit=True, configuration='quad' ) # Call this procedure whenever the panel configuration changes due to # stepping through the panel history (ie. pressing either the "Forward" # or "Back" buttons. This procedure will update the value of the # option menu to reflect the new pane layout configuration. # def ExampleUpdateConfiguration( optionMenuGrp, paneLayout ): if optionMenuGrp == "" or paneLayout == "": return configuration = pm.paneLayout( paneLayout, query=True, configuration=True ); if configuration == 'single': pm.optionMenuGrp( optionMenuGrp, edit=True, value='Single' ) elif configuration == 'horizontal2': pm.optionMenuGrp( optionMenuGrp, edit=True, value='2 Stacked' ) elif configuration == 'vertical2': pm.optionMenuGrp( optionMenuGrp, edit=True, value='2 Side by Side' ) elif configuration == 'quad': pm.optionMenuGrp( optionMenuGrp, edit=True, value='Four' )