UIUtils
=== Author: Assaf Ben Zur ===
UI Utility function assembly.
This module holds all UI utility functions as well s any QT dynamic draw functions.
All UI functions should be held in here for multi-usage of the same UI draw functions.
This module also holds the QT ui dynamic conversion to '.py' and the 'get_maya_window' function.
Classes
CollapsibleFrameWidget [Class]
Collapsible frame Widget class.
This is a wrapper widget that allows for a collapisble frame to be built.
The QFrame object will allow for Layouts to be inserted into the Collapsible frame, inserting any widgets within it,
collapsing and expanding it by a click trigger (from the user).
Constructor: | CollapsibleFrameWidget(parent(str) ; [default: None],title(str) ; [default: None]) |
Inherits from: | QFrame |
Class Members: |
|
Methods: |
|
CollapsibleFrameWidget methods
addWidget [CollapsibleFrameWidget class method]
Constructor: | addWidget(self, widget) |
Return: | None |
Arguments: |
|
Optional Arguments: |
initArrow [CollapsibleFrameWidget class method]
Constructor: | initArrow(self, collapsed) |
Return: | None |
Arguments: |
|
Optional Arguments: |
initCollapsable [CollapsibleFrameWidget class method]
Constructor: | initCollapsable(self) |
Return: | None |
Arguments: |
|
Optional Arguments: |
initContent [CollapsibleFrameWidget class method]
Constructor: | initContent(self, collapsed) |
Return: | None |
Arguments: |
|
Optional Arguments: |
initTitleFrame [CollapsibleFrameWidget class method]
Constructor: | initTitleFrame(self, title, collapsed) |
Return: | None |
Arguments: |
|
Optional Arguments: |
setArrow [CollapsibleFrameWidget class method]
Constructor: | setArrow(self, arrow_dir) |
Return: | None |
Arguments: |
|
Optional Arguments: |
toggleCollapsed [CollapsibleFrameWidget class method]
Constructor: | toggleCollapsed(self) |
Return: | None |
Arguments: |
|
Optional Arguments: |
MnsAbout [Class]
Mansur - About dialog
Constructor: | MnsAbout(parent(str) ; [default: get_maya_window()],version(str) ; [default: "dev"]) |
Inherits from: | QtWidgets.QDialog |
Class Members: |
|
extraChannelsDelegate [Class]
Constructor: | extraChannelsDelegate(parent(str) ; [default: None],*args) |
Inherits from: | QtWidgets.QItemDelegate |
Class Members: | |
Methods: |
|
extraChannelsDelegate methods
createEditor [extraChannelsDelegate class method]
Constructor: | createEditor(self, parent, option, index) |
Return: | None |
Arguments: |
|
Optional Arguments: |
setModelData [extraChannelsDelegate class method]
Constructor: | setModelData(self, editor, model, index) |
Return: | None |
Arguments: |
|
Optional Arguments: |
Defenitions
acquireExternalWindow
A simple method to acquire an external QT window, into an actual PyQt MianWindow object.
Constructor: | acquireExternalWindow(UIName = None) |
Return: | QMainWindow (UI Class) |
Arguments: |
|
Keyword Arguments: |
applyCollapsibleWidgetsForPairing
Constructor: | applyCollapsibleWidgetsForPairing(pairing = [], expandedTabs = []) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
buildFormBaseClassForUI
Constructor: | buildFormBaseClassForUI(script_dir, rel_path) |
Return: | baseClass, formClass |
Arguments: |
|
Keyword Arguments: |
buildStackedTabForModuleParentDir
Main BLOCK dynamiuc tab builder.
Builds a tab for a given tab parent including all the neccesary layouts within, returning the main layout that can be inserted with new q items.
Constructor: | buildStackedTabForModuleParentDir(modDirName, insertIndex, tabWidget, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
buildTabForModuleParentDir
Main BLOCK dynamiuc tab builder.
Builds a tab for a given tab parent including all the neccesary layouts within, returning the main layout that can be inserted with new q items.
Constructor: | buildTabForModuleParentDir(modDirName, insertIndex, tabWidget, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
checkChannelCommand
DynUI 'channel control' checkBox changed command trigger.
Constructor: | checkChannelCommand(chanBtn,chanCbxs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
colOverrideBlockDefTriggerCommand
DynUI color-override default command trigger.
Constructor: | colOverrideBlockDefTriggerCommand(colorOverrideCbx, sideCB, ovverideBtnList) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
colOverrideStateChange
DynUI color-override changed command trigger.
Constructor: | colOverrideStateChange(colorOverrideCbx, sideCB, ovverideBtnList) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
convertRelativePathToAbs
A method for replacing a projectRoot variable within a relative path to the absolute path
Based on the current project directory
Constructor: | convertRelativePathToAbs(filePath = "") |
Return: | string |
Arguments: |
|
Keyword Arguments: |
createAboutWindow
Load about dialog
Constructor: | createAboutWindow() |
Return: | None |
Arguments: | |
Keyword Arguments: |
createTextSeparator
Constructor: | createTextSeparator(label = "", QMenuItem = None, parent = get_maya_window()) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
customScriptsAddCommand
Add button trigger command for "custom scripts" slot of synamic UI.
Constructor: | customScriptsAddCommand(listWidget) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
customScriptsDefaultCommand
Default trigger command for 'custom scripts' slot in dynUI.
Constructor: | customScriptsDefaultCommand(listWidget, MnsArgumentObj) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
customScriptsRemoveCommand
Remove button trigger command for "custom scripts" slot of synamic UI.
Constructor: | customScriptsRemoveCommand(listWidget) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
deleteAllLayoutItems
A method to delete all widgets/object from a given layout
Constructor: | deleteAllLayoutItems(layout, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
drawBooleanChk
Main dynamic check-box UI draw.
Creates a simple boolean check-box (QCheckBox) as well as a connected 'default' button.
Constructor: | drawBooleanChk(MnsArgumentObj, layoutParent) |
Return: | QCheckBox |
Arguments: |
|
Keyword Arguments: |
drawButtonAndField
Main dynamic 'button and field' draw.
Draws a deault button, text field and an 'Insert items from scene' button into the given parent layout.
This function makes all relevant connections between the QItems created-
-
'Load command' from the QPushButton (insert) to the text field
-
'Clear' trigger for the text field.
-
'Set default' from the QPushButton 'default' to the text field.
These connections are made within in order the return the QLEdit only, with no need to worrie about the 'functionallity' buttons created, only the value within the text field.
Constructor: | drawButtonAndField(MnsArgumentObj, layoutParent, alphaLimit = False) |
Return: | QLEdit |
Arguments: |
|
Keyword Arguments: |
drawButtonAndFieldUnknown
Main 'unknown' button and field UI draw.
In case the MnsArgument.type in question is an unknown type, draw a button and field style item for it.
Constructor: | drawButtonAndFieldUnknown(MnsArgumentObj, layoutParent) |
Return: | QLEdit |
Arguments: |
|
Keyword Arguments: |
drawChannelColumnAndConnect
Draw channel column (part of channel control) into a DynUI.
Constructor: | drawChannelColumnAndConnect(MnsArgumentObj, channel, **kwargs) |
Return: | QVBoxLayout (layout), list (drawen boxes) |
Arguments: |
|
Keyword Arguments: |
drawChannelControl
Draw the predefined channel-control slot into a DynUI.
Constructor: | drawChannelControl(MnsArgumentObj, layoutParent, **kwargs) |
Return: | list (all channel cbxs) |
Arguments: |
|
Keyword Arguments: |
drawColorBox
Main dynamic 'draw color box' creation function.
Will create a new QPushButton with its 'color picker' style display and inserts it into the given layoutParent.
An automatic connection to the 'getColor' function is made, as well as a 'default' button creation and connection is made.
Constructor: | drawColorBox(MnsArgumentObj, layoutParent) |
Return: | QPushButton |
Arguments: |
|
Keyword Arguments: |
drawColorBtnAndConnect
Constructor: | drawColorBtnAndConnect(default, **kwargs) |
Return: | QPushButton |
Arguments: |
|
Keyword Arguments: |
|
drawColorScheme
Main block 'draw color scheme box' creation function.
Will create a new QPushButton series with 'color picker's style display and inserts it into the given layoutParent.
An automatic connection to the 'getColor' function is made, as well as a 'default' button creation and connection is made.
Constructor: | drawColorScheme(MnsArgumentObj, layoutParent) |
Return: | list |
Arguments: |
|
Keyword Arguments: |
drawColorSchemeOverride
Draw the predefined 'color scheme' slot into a dynUI.
Constructor: | drawColorSchemeOverride(MnsArgumentObj, layoutParent, **kwargs) |
Return: | list |
Arguments: |
|
Keyword Arguments: |
|
drawCustomScriptsSlot
draw a "custom scripts" slot into dyn UI.
Constructor: | drawCustomScriptsSlot(MnsArgumentObj, layoutParent) |
Return: | QListWidget |
Arguments: |
|
Keyword Arguments: |
drawExtraChannelsBox
Main dynamic 'draw blend shape targets box' creation function.
Constructor: | drawExtraChannelsBox(MnsArgumentObj, layoutParent) |
Return: | QTreeWidget |
Arguments: |
|
Keyword Arguments: |
drawFloatScroll
Main dynamic "Float spinner" UI draw
Creates a Float QDoubleSpinBox widget, and a default button connected to it.
Constructor: | drawFloatScroll(MnsArgumentObj, layoutParent) |
Return: | QDoubleSpinBox |
Arguments: |
|
Keyword Arguments: |
drawHorizontalDevider
Draw a simple Horizontal devider into the dynUI.
Constructor: | drawHorizontalDevider(MnsArgumentObj, layoutParent) |
Return: | QFrame (Horizontal line devider) |
Arguments: |
|
Keyword Arguments: |
drawIntSpinner
Main dynamic 'int field' field and spinner UI draw.
Creates an int QSpinBox widget, and a default button connected to it.
Constructor: | drawIntSpinner(MnsArgumentObj, layoutParent) |
Return: | QSpinBox |
Arguments: |
|
Keyword Arguments: |
drawJntStructMemberCol
Constructor: | drawJntStructMemberCol(layout = None, argument = None) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
drawModuleButton
Main BLOCK dynamic build module buttom function draw.
Builds a new QPushButoon for a given module, return the QPushButton created after connecting it to the given 'connectFunction'.
The QPush buttom created will then to be inserted into a layout by the caller function.
Constructor: | drawModuleButton(MnsBuildModuleObj, connectFunction) |
Return: | QPushButton |
Arguments: |
|
Keyword Arguments: |
drawOptionBox
Main dynamic 'option box' draw.
Drawing a new ob based on parameters within the MnsArgument object passed in.
The QComboBox is inserted into the parent layout passed in.
A default button and connection is made.
Constructor: | drawOptionBox(MnsArgumentObj, layoutParent) |
Return: | QComboBox |
Arguments: |
|
Keyword Arguments: |
drawPathField
Main Path row draw
Constructor: | drawPathField(MnsArgumentObj, layoutParent) |
Return: | QLEdit |
Arguments: |
|
Keyword Arguments: |
drawPrimaryButton
Picker method- draw a generic picker button.
Constructor: | drawPrimaryButton(plg, tabWidget, pickerBase, picker) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
drawSpacesBox
Main dynamic 'draw spaces box' creation function.
Constructor: | drawSpacesBox(MnsArgumentObj, layoutParent, **kwargs) |
Return: | QListWidget |
Arguments: |
|
Keyword Arguments: |
dynUIExtraChannelsMenu
Constructor: | dynUIExtraChannelsMenu(treeWG, position) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsAddDivider
Constructor: | extraChannelsAddDivider(treeWG, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsAddRow
Constructor: | extraChannelsAddRow(treeWG, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsChangeDirection
Constructor: | extraChannelsChangeDirection(treeWG, direction = 1) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsDuplicateRows
Constructor: | extraChannelsDuplicateRows(treeWG, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsEdit
Constructor: | extraChannelsEdit(item, col) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsLoadCBSel
Constructor: | extraChannelsLoadCBSel(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsMoveItemsDown
Constructor: | extraChannelsMoveItemsDown(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsMoveItemsUp
Constructor: | extraChannelsMoveItemsUp(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsRemoveSelected
Constructor: | extraChannelsRemoveSelected(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extraChannelsValidateCurrentData
Constructor: | extraChannelsValidateCurrentData(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
extractAllMayaIcons
Constructor: | extractAllMayaIcons() |
Return: | None |
Arguments: | |
Keyword Arguments: |
fourKWindowAdjust
Constructor: | fourKWindowAdjust(window) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
fourKWindowRevert
Constructor: | fourKWindowRevert(window) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
getColor
Simple 'get color for a color PButton'.
Creates a new QColorDialog asking the user for a color choice.
When color selected sets the caller QPushButton color to the selected color
Constructor: | getColor(btn, **kwargs) |
Return: | tuple[3] (color) |
Arguments: |
|
Keyword Arguments: |
|
getColorArrayFromColorScheme
Collect a normalized array of colors from a 'colorSceheme' enum attribute.
Constructor: | getColorArrayFromColorScheme(side, colorScheme) |
Return: | list (color sceheme) |
Arguments: |
|
Keyword Arguments: |
getEulaText
get the most recent eula.
Constructor: | getEulaText() |
Return: | None |
Arguments: | |
Keyword Arguments: |
getGuiStyle
Constructor: | getGuiStyle() |
Return: | None |
Arguments: | |
Keyword Arguments: |
getObjectScreenSpaceByFilmGate
This method is used to 'project' a plg into the projection camera's film gate.
Get the relative position of the plg to the camera film-gate's top left corener.
Constructor: | getObjectScreenSpaceByFilmGate(objectProj, cam) |
Return: | float, float (posX, posY) |
Arguments: |
|
Keyword Arguments: |
getPathCommand
Dyn UI path slot 'get path' command trigger.
Constructor: | getPathCommand(LEdit, mode = 0, fileTypes = []) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
getPlgPosition
Get the relative position of the requested plg, based on the 'Picker Layout Base' Guide top left corner.
Return the local bounding box size as well.
Constructor: | getPlgPosition(plg, pickerBase) |
Return: | float,float,float,float (posX,PosY,Width,Height) |
Arguments: |
|
Keyword Arguments: |
getWindow
Constructor: | getWindow(windowName = "") |
Return: | None |
Arguments: |
|
Keyword Arguments: |
get_maya_window
Main maya window get for a global UI parent
Constructor: | get_maya_window() |
Return: | qtWindow (main maya window as a qt window) |
Arguments: | |
Keyword Arguments: |
listLoadCmd
Load to list command trigger (dynUI)
Constructor: | listLoadCmd(QListWidget) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
listRemoveCommand
Remove from list command trigger (dynUI)
Constructor: | listRemoveCommand(QListWidget) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
loadCmd
Main text field 'load from scene' trigger command.
This command will update the given QLEdit with members of the maya scene when triggered.
Three main cases:
-
Nothing is selected - if the field is empty- do nothing, else clear the field.
-
objects are selected, without any CB selection - load the object names in, seperated by commas.
-
Objects are selected and there is a CB selection as well - load all objects and chnnels in a 'object.channel' format, seperated by commas.
Constructor: | loadCmd(LEdit) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
load_ui_type
This function converts a '.ui' file into a '.py' file live.
This means that all UI's are derived from a QT designer ui files that are converted directly to form the UI.
This keeps a live connection between the '.ui' file and the actul UI in maya. Meaning that any edit or a change to the UI base needs to be done only from the QT designer, without any further action by the user.
It reruns a baseClass and a formClass to be used when creating any UI.
Constructor: | load_ui_type(ui_file) |
Return: | baseClass, formClass |
Arguments: |
|
Keyword Arguments: |
optionBoxTextTrigger
Constructor: | optionBoxTextTrigger(comboBox = None, lineWditWidget = None, index = 0) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
readGuiStyle
Constructor: | readGuiStyle(scheme = "dark", **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
recDeleteAllLayoutItems
A method to delete all widgets/object from a given layout
Constructor: | recDeleteAllLayoutItems(layout, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
relativePathCheck
A method for checking if any file path can be converted to a relative path.
If relative path is available, promt a message asking the user if he want to convert.
if so, convert and return.
Constructor: | relativePathCheck(filePath = "") |
Return: | string |
Arguments: |
|
Keyword Arguments: |
reloadWindow
Constructor: | reloadWindow(windowName = "") |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setBooleanDefaultCmd
'Set default' trigger for a QCheckBox item.
Constructor: | setBooleanDefaultCmd(cbx,default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setChennelControlDefaultCmd
DynUI chennel control slot default command trigger.
Constructor: | setChennelControlDefaultCmd(cbxList, MnsArgumentObj) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setColorDefaultCmd
A 'set color back to default command.
A command to be triggered by an outside 'default' button, or when initializing to set the specified QPushButton color back to it's default value.
Constructor: | setColorDefaultCmd(btn, colorDef) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setColorSchemeDefaultCmd
DynUI color-scheme default command trigger.
Constructor: | setColorSchemeDefaultCmd(btnList, default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setFloatDefaultCmd
'Set default' trigger for a QDoubleSpinBox item.
Constructor: | setFloatDefaultCmd(spinner,default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setIntDefaultCmd
'Set deafult' command trigget for an int QSpinBox.
Constructor: | setIntDefaultCmd(spinner,default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setIntIncrement
Constructor: | setIntIncrement(spinner, increment, start) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setLinkToQLabel
Constructor: | setLinkToQLabel(labelObj = None, ahref = "") |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setListWidgetDefaultCommand
'Default' command trigger for a 'list' type synamic row (dynUI)
Constructor: | setListWidgetDefaultCommand(QListWidget, default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setOtionBoxDefaultCmd
A 'set default' command to be triggered for a combo box item.
Constructor: | setOtionBoxDefaultCmd(cbox, default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setSpaceDefault
Constructor: | setSpaceDefault(listWG, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
setStringDefaultCmd
'Set default' command trigger from a text field
Constructor: | setStringDefaultCmd(LEdit,default) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
sideCBChangedTriggerCommand
DynUI side combo box changed command trigger.
Constructor: | sideCBChangedTriggerCommand(colorOverrideCbx, sideCB, ovverideBtnList, rigTop, ignoreOvverideCheckbox = False) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
tearOffWindow
Create a new maya 'tear-off' panel.
Constructor: | tearOffWindow(name, title, width, height, cameraToView) |
Return: | pymel.core.window (tear-off window) |
Arguments: |
|
Keyword Arguments: |
toQtObject
Convert a maya UI component into a QT object
Constructor: | toQtObject(mayaName, **kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |