PyQt

Mayaui

dpiScale(value)

Get the appropriate QSize based on maya’s current dpi setting

Parameters

value (int or float) –

Returns

Return type

int

sizeByDpi(size)

Scales the QSize by the current dpi scaling from maya.

Parameters

size (QSize) – The QSize to Scale by the dpi setting from maya

Returns

The newly scaled QSize

Return type

QSize

mayaWindow()
Returns

instance, the mainWindow ptr as a QMainWindow widget.

Return type

QtWidgets.QMainWindow

getMayaWindow()
Returns

instance, the mainWindow ptr as a QMainWindow widget.

Return type

QtWidgets.QMainWindow

mayaViewport()

Returns the currently active maya viewport as a widget :return: :rtype:

fullName(widget)
getMayaWindowName()

Returns the maya window objectName from Qt :return:

toQtObject(mayaName, widgetType=MockExt.QtWidgets.QWidget)

Convert a Maya ui path to a Qt object.

Parameters

mayaName – Maya UI Path to convert eg. “scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|testButton”

Returns

PyQt representation of that object

Return type

QtWidgets.QWidget

outlinerPaths()
getOutliners()
openGraphEditor()
statusLineLayout()

Returns the maya status line as a QLayout

Return type

QtWidgets.QLayout

applyScriptEditorHistorySyntax(sourceType, highlighter=None, **kwargs)
highlighterEditorWidget(sourceType, **kwargs)
suppressOutput()

Supresses all output to the script editor

restoreOutput()

Restores the script editor to include all results

setChannelBoxAtTop(channelBox, value)
Parameters
  • channelBox (str) – mainChannelBox

  • value (bool) –

setChannelBoxAtTop("mainChannelBox",True)
setChannelShowType(channelBox, value)
Parameters
  • channelBox (str) – mainChannelBox

  • value (str) –

setChannelShowType("mainChannelBox", "all")
activeModelEditor()

Get the model editor with focus.

modelEditors()

Returns all maya model editors

disableColorManagement(editors=None)

Disables color management for modelEditors.

Parameters

editors (list of basestring) – List of Model Editors to disable.

Returns

bool, True

enableColorManagement(editors=None)

Disables color management for modelEditors.

Parameters

editors (list[str]) – List of Model Editors to disable.

Returns

bool

setModelEditorColorManagement(editor, value)
rebuild(objectName)

If the bootstrap widget exists then we reapply it to mayas layout, otherwise do nothing.

Parameters

objectName (str) – the bootStrap objectName

bootstrapDestroyWindow(objectName)

Function to destroy a bootstrapped widget, this use the maya workspaceControl objectName

Parameters

objectName (str) – The bootstrap Widget objectName

Return type

bool

class BootStrapWidget(*args: Any, **kwargs: Any)

Bases: MockExt., MockExt.QtWidgets.

Class to wrap mayas workspace dockable mixin into something useful,

customWidget = QtWidget()
boostrap = BootStrapWidget(customWidget, "customWidget")
boostrap.show(dockable=True, retain=False, width=size.width(), widthSizingProperty='preferred',
             minWidth=minSize.width(),
             height=size.height(), x=250, y=200)
INITIAL_SIZE
PREFERRED_SIZE
MINIMUM_SIZE
setSizeHint(size)
close(*args, **kwargs)

Overridden to call the bootstrap user widget.close()

show(**kwargs)
dockableShow(*args, **kwargs)

Copied from mayaMixin.MayaQWidgetDockableMixin().show() so we can tweak the docking settings.

Nodeeditor

getPrimaryNodeEditor()

Find and return the name of the primary node editor if it exists.

Returns

The node editor name

Return type

str

createNodeEditor()

Creates(opens) the maya node editor.

Returns

Returns the NodeEditorWrapper object linked to the current node editor.

Return type

NodeEditorWrapper

currentNodeEditorPanel()

Returns the currently active node editor panel if any.

Returns

The maya node editor panel name

Return type

str

currentNodeEditor()

Returns the currently active nodeEditor name if any.

Note

This function should be used when using NodeEditorWrapper if you want to work with the current active Node Editor.

Note

This is not the same getPrimaryEditor() which doesn’t depend on user focus.

Returns

The maya node editor path

Return type

””

class NodeEditorWrapper(*args: Any, **kwargs: Any)

Bases: MockExt.QtCore.

ATTR_VIEW_SIMPLE = 0
ATTR_VIEW_CONNECTED = 1
ATTR_VIEW_ALL = 2
ATTR_VIEW_CUSTOM = 3
static nodeEditorAsQtWidgets(nodeEditor)
static itemsRect(items)
exists()
show()
selectedNodeItems()
selectedConnections()
addNodes(nodes)

Adds a list of nodes to the current node editor

Parameters

nodes (list(om2.MObject)) – a list of maya mobject representing valid nodes

addNodesOnCreate()
setAddNodesOnCreate(state)
setNodeAttributeDisplay(viewMode)

Sets either the currently selected node or all viewed nodes attribute display to one of the follow states,ATTR_VIEW_SIMPLE, ATTR_VIEW_CONNECTED, ATTR_VIEW_ALL and ATTR_VIEW_CUSTOM.

Parameters

viewMode (int) – View mode based on NodeEditorWrapper.VIEW_MODE_# .

graphDownstreamFromSelection()

This Graphs the downstream nodes from the currently selected nodes.

itemTypeUnderCursor()
plugUnderCursor()
graphDownstreamFromPlug(plug)
graphUpstreamFromPlug(plug)
connectedGraphingModeContext()
alignLeft(items=None)
alignRight(items)
alignTop(items)
alignBottom(items)
alignCenterX(items)
alignCenterY(items)

Scripteditor

class ScriptEditorState

Bases: object

Provides methods to suppress and restore script editor output.

suppress_results = None
suppress_errors = None
suppress_warnings = None
suppress_info = None
classmethod suppress_output()

Hides all script editor output.

classmethod restore_output()

Restores the script editor output settings to their original values.

Change Renderer UI

ui_loadRenderer(renderer)

Popup window for loading a renderer

Parameters

renderer (str) – Renderer nicename

Return okPressed

Was the ok button pressed or not

Rtype okPressed

bool

checkRenderLoaded(renderer, bypassWindow=False)

Checks that the renderer is loaded, if not opens a window asking the user to load it

Parameters
  • renderer (str) – the nice name of the renderer “Arnold” or “Redshift” etc

  • bypassWindow (bool) – If True don’t show the popup window, just return if the renderer is loaded or not

Return rendererLoaded

True if the renderer is loaded

Rtype rendererLoaded

bool

globalChangeRenderer(renderer, toolsets)

Updates all GUIs with the current renderer.

From toolset code run:

toolsets = toolsetui.toolsets(attr="global_receiveRendererChange")
self.generalSettingsPrefsData = elements.globalChangeRenderer(self.properties.rendererIconMenu.value,
                                                              toolsets,
                                                              self.generalSettingsPrefsData,
                                                              pc.PREFS_KEY_RENDERER)
Parameters
  • renderer (str) – The renderer nice name to change to for all UIs

  • toolsets (list) – A list of all the toolset UIs to change. Should be strings but may be objects.

Returns

The preferences data file now updated

Return type

object

Cmds Widgets

class MayaColorBtn(*args: Any, **kwargs: Any)

Bases: MockExt.QtWidgets., zoo.libs.pyqt.extended.menu.MenuCreateClickMethods

colorChanged
colorDragged
colorClicked
setColorMinimumWidth(width)

Set the minimum width of the color widget

Parameters

width

Returns

setColorMinimumHeight(height)

Set the minimum height of the color widget

Parameters

width

Returns

text()

returns the label name as a string

Return labelName

the text name of the label

Rtype labelName

str

fullName()
setColorFixedWidth(width)

Sets the size of the color widget, dpi scale handled

Parameters

width (int) – Width in pixels of the color btn

setColorFixedHeight(height)

sets the size of the color widget, dpi scale handled

setDisabled(disabled=True)
setEnabled(enabled=True)
setDisabledLabel(disabled=True)
setColorLinearFloat(color, noEmit=True)

Sets the color as renderspace color (or linear) in 0-1.0 float ranges Eg (1.0, .5, .6666)

emits the color as a Srgb Int color Eg (0, 255, 134)

setColorSrgbFloat(color, noEmit=True)

sets the color as display tuple with 0-1.0 float ranges Eg (1.0, .5, .6666) emits the color as a display Int color Eg (0, 255, 134)

Note: Maya 2023 and above this now supports Display Color as SRGB. 2022 and below is SRGB only.

Parameters
  • color (list(float)) – Color as display color float 0-1.0

  • noEmit (bool) – Emit the color?

setColorSrgbInt(color, noEmit=True)

Sets the color as srgb Int tuple with 0-255 integer ranges Eg (0, 255, 134)

Emits the color as a Srgb Int color Eg (0, 255, 134)

Note: Maya 2023 and above this now supports Display Color as SRGB. 2022 and below is SRGB only.

Parameters
  • color (list(int)) – Color as display color 0-255 integer. Always srgb in 2022 and below.

  • noEmit (bool) – Emit the color?

colorLinearFloat()

returns the color of the color picker in linear color With 0-1.0 float ranges Eg (1.0, .5, .6666), the color is in Linear color, not SRGB

colorSrgbInt()

returns rgb tuple with 0-255 ranges Eg (128, 255, 12)

colorSrgbFloat()

returns rgb tuple with 0-1.0 float ranges Eg (1.0, .5, .6666)

data()

Returns the stored dictionary key (None by default) and a hex color. The key is usually a dictionary key that is passed in on creation of the instance, used in stylesheets This method is pretty specific to stylesheets and could be moved, method must be named data

Return self.key

the dict key passed into the initialise function, stylesheet key “FRAMELESS_TITLELABEL_COLOR”

Rtype self.key

str

Return hexColor

the color as hex, 6 letters eg ffffff

Rtype hexColor

str

setMenu(menu, modeList=None, mouseButton=MockExt.QtCore.Qt.RightButton)

Add the left/middle/right click menu by passing in a QMenu,

Note

Only works on the label currently.

If a modeList is passed in then create/reset the menu to the modeList:

[("icon1", "menuName1"), ("icon2", "menuName2")]

If no modelist the menu won’t change.

Parameters
  • menu (QtWidgets.QMenu) – The Qt menu to show on middle click.

  • modeList (list(tuple(str))) – Menu modes. eg [(“icon1”, “menuName1”), (“icon2”, “menuName2”)]

  • mouseButton (QtCore.Qt.ButtonClick) – the mouse button clicked QtCore.Qt.LeftButton, QtCore.Qt.RightButton, QtCore.Qt.MiddleButton

addActionList(modes, mouseButton=MockExt.QtCore.Qt.RightButton)

resets the appropriate mouse click menu with the incoming modes

Note: only works on the label currently

modeList: [(“icon1”, “menuName1”), (“icon2”, “menuName2”), (“icon3”, “menuName3”)]

resets the lists and menus:

self.menuIconList: [“icon1”, “icon2”, “icon3”] self.menuIconList: [“menuName1”, “menuName2”, “menuName3”]

Parameters
  • modes (list(tuple(str))) – a list of menu modes (tuples) eg [(“icon1”, “menuName1”), (“icon2”, “menuName2”)]

  • mouseButton (QtCore.Qt.ButtonClick) – the mouse button clicked QtCore.Qt.LeftButton, QtCore.Qt.RightButton, QtCore.Qt.MiddleButton

class MayaColorHsvBtns(*args: Any, **kwargs: Any)

Bases: MockExt.QtWidgets., zoo.libs.pyqt.extended.menu.MenuCreateClickMethods

offsetClicked
hsvShowHide(showHue=True, showSat=True, showValue=True)

Hide/show the hue saturation buttons

Parameters
  • showHue (bool) – Show/hide the hues buttons

  • showSat (bool) – Show/hide the hues buttons

  • showValue (bool) – Show/hide the hues buttons

class MayaColorSlider(*args: Any, **kwargs: Any)

Bases: MockExt.QtWidgets.

colorChanged
sliderChanged
sliderPressed
sliderReleased
colorSliderChanged
text()

returns the label name as a string

Return labelName

the text name of the label

Rtype labelName

str

setColorBtnWidth(width)

Sets the color button widget width, dpi scale handled, will scale with cmds as pyside has issues overriding.

Not Tested should work.

Parameters

width (int) – pixel width of the color button.

setColorBtnHeight(height)

Sets the size of the color button widget, dpi scale handled

setDisabled(disabled=True)

Disables the color button, slider and label so it cannot be clicked

setEnabled(enabled=True)

Enables the color button, slider and label so it cannot be clicked

setDisabledLabelSlider(disabled=True)

Disables the color widget label and slider, the color picker and slider will work as per normal

setColorLinearFloat(color, noEmit=True)

Sets the color as linear color in 0-1.0 float ranges Eg (1.0, .5, .6666) emits the color as a Srgb Int color Eg (0, 255, 134)

Parameters
  • color (tuple(float)) – color as linearFloat (1.0, .5, .6666)

  • noEmit (bool) – Block the signals so no emit takes place

setColorSrgbFloat(color, noEmit=True)

Sets the color as srgb tuple with 0-1.0 float ranges Eg (1.0, .5, .6666) emits the color as a Srgb Int color Eg (0, 255, 134)

Parameters
  • color (tuple(float)) – color as srgbFloat (1.0, .5, .6666)

  • noEmit (bool) – Block the signals so no emit takes place

setColorSrgbInt(color, noEmit=True)

Sets the color as srgb Int tuple with 0-255 int ranges Eg (0, 255, 134) emits the color as a Srgb Int color Eg (0, 255, 134)

Parameters
  • color (tuple(int)) – color as srgbInt (0, 255, 134)

  • noEmit (bool) – Block the signals so no emit takes place

colorLinearFloat()

Returns the color of the color picker in linear color With 0-1.0 float ranges Eg (1.0, .5, .6666), the color is in Linear color, not srgb

Return colorLinearFloat

color in linear float range, eg (1.0, .5, .6666)

Rtype colorLinearFloat

tuple(float)

colorSrgbInt()

Returns rgb tuple with 0-255 ranges Eg (128, 255, 12)

Return colorSrgbInt

color in srgb int range, eg (128, 255, 12)

Rtype colorSrgbInt

tuple(int)

colorSrgbFloat()

Returns rgb tuple with 0-1.0 float ranges Eg (1.0, .5, .6666)

Return colorSrgbFloat

color in srgb float range, eg (1.0, .5, .6666)

Rtype colorSrgbFloat

tuple(float)

uiConnections()

Setup the emit signals