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
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: |
- _is_collasped
- _title_frame
- _content
- _main_v_layout
- clickedSignal
|
Methods: |
|
initCollapsable [CollapsibleFrameWidget class method]
Constructor: | initCollapsable(self) |
Return: | None |
Arguments: |
|
Optional Arguments: |
toggleCollapsed [CollapsibleFrameWidget class method]
Constructor: | toggleCollapsed(self) |
Return: | None |
Arguments: |
|
Optional Arguments: |
setArrow [CollapsibleFrameWidget class method]
Constructor: | setArrow(self, arrow_dir) |
Return: | None |
Arguments: |
|
Optional Arguments: |
initArrow [CollapsibleFrameWidget class method]
Constructor: | initArrow(self, collapsed) |
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: |
addWidget [CollapsibleFrameWidget class method]
Constructor: | addWidget(self, widget) |
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: |
- iconsDir
- versionDisplay
- close_btn
|
Constructor: | extraChannelsDelegate(parent(str) ; [default: None],*args) |
Inherits from: | QtWidgets.QItemDelegate |
Class Members: |
|
Methods: |
|
setModelData [extraChannelsDelegate class method]
Constructor: | setModelData(self, editor, model, index) |
Return: | None |
Arguments: |
|
Optional Arguments: |
createEditor [extraChannelsDelegate class method]
Constructor: | createEditor(self, parent, option, 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: | None |
Arguments: |
- UIName(str) ; [default: None]
|
Keyword Arguments: |
Constructor: | buildFormBaseClassForUI(script_dir, rel_path) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
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: |
- modDirName
- insertIndex
- tabWidget
- kwargs
|
Keyword Arguments: |
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: |
- modDirName
- insertIndex
- tabWidget
- kwargs
|
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: |
- colorOverrideCbx
- sideCB
- ovverideBtnList
|
Keyword Arguments: |
colOverrideStateChange
DynUI color-override changed command trigger.
Constructor: | colOverrideStateChange(colorOverrideCbx, sideCB, ovverideBtnList) |
Return: | None |
Arguments: |
- colorOverrideCbx
- sideCB
- ovverideBtnList
|
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: | None |
Arguments: |
- filePath(str) ; [default: ""]
|
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: |
- label(str) ; [default: ""]
- QMenuItem(str) ; [default: None]
- parent(str) ; [default: get_maya_window()]
|
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: |
- listWidget
- MnsArgumentObj
|
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
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.
Constructor: | drawButtonAndField(MnsArgumentObj, layoutParent, alphaLimit = False) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
- alphaLimit(bool) ; [default: False]
|
Keyword Arguments: |
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawChannelColumnAndConnect
Draw channel column (part of channel control) into a DynUI.
Constructor: | drawChannelColumnAndConnect(MnsArgumentObj, channel, kwargs) |
Return: | None |
Arguments: |
- MnsArgumentObj
- channel
- kwargs
|
Keyword Arguments: |
drawChannelControl
Draw the predefined channel-control slot into a DynUI.
Constructor: | drawChannelControl(MnsArgumentObj, layoutParent, kwargs) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
- kwargs
|
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawColorBtnAndConnect
Constructor: | drawColorBtnAndConnect(default, kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
- buttonSize(int) ; [default: 25]
- colOverrideCbx(str) ; [default: None]
|
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawColorSchemeOverride
Draw the predefined 'color scheme' slot into a dynUI.
Constructor: | drawColorSchemeOverride(MnsArgumentObj, layoutParent, kwargs) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
- kwargs
|
Keyword Arguments: |
drawCustomScriptsSlot
draw a "custom scripts" slot into dyn UI.
Constructor: | drawCustomScriptsSlot(MnsArgumentObj, layoutParent) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
Main dynamic 'draw blend shape targets box' creation function.
Constructor: | drawExtraChannelsBox(MnsArgumentObj, layoutParent) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
Main dynamic "Float spinner" UI draw
Creates a Float QDoubleSpinBox widget, and a default button connected to it.
Constructor: | drawFloatScroll(MnsArgumentObj, layoutParent) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawHorizontalDevider
Draw a simple Horizontal devider into the dynUI.
Constructor: | drawHorizontalDevider(MnsArgumentObj, layoutParent) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawJntStructMemberCol
Constructor: | drawJntStructMemberCol(layout = None, argument = None) |
Return: | None |
Arguments: |
- layout(str) ; [default: None]
- argument(str) ; [default: None]
|
Keyword Arguments: |
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: | None |
Arguments: |
- MnsBuildModuleObj
- connectFunction
|
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: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
drawPathField
Main Path row draw
Constructor: | drawPathField(MnsArgumentObj, layoutParent) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
|
Keyword Arguments: |
Picker method- draw a generic picker button.
Constructor: | drawPrimaryButton(plg, tabWidget, pickerBase, picker) |
Return: | None |
Arguments: |
- plg
- tabWidget
- pickerBase
- picker
|
Keyword Arguments: |
drawSpacesBox
Main dynamic 'draw spaces box' creation function.
Constructor: | drawSpacesBox(MnsArgumentObj, layoutParent, kwargs) |
Return: | None |
Arguments: |
- MnsArgumentObj
- layoutParent
- kwargs
|
Keyword Arguments: |
Constructor: | dynUIExtraChannelsMenu(treeWG, position) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsAddDivider(treeWG, kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsAddRow(treeWG, kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsChangeDirection(treeWG, direction = 1) |
Return: | None |
Arguments: |
- treeWG
- direction(int) ; [default: 1]
|
Keyword Arguments: |
Constructor: | extraChannelsDuplicateRows(treeWG, kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsEdit(item, col) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsLoadCBSel(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsMoveItemsDown(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsMoveItemsUp(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsRemoveSelected(treeWG) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
Constructor: | extraChannelsValidateCurrentData(treeWG) |
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: | None |
Arguments: |
|
Keyword Arguments: |
getColorArrayFromColorScheme
Collect a normalized array of colors from a 'colorSceheme' enum attribute.
Constructor: | getColorArrayFromColorScheme(side, colorScheme) |
Return: | None |
Arguments: |
|
Keyword Arguments: |
getEulaText
get the most recent eula.
Constructor: | getEulaText() |
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: | None |
Arguments: |
|
Keyword Arguments: |
getPathCommand
Dyn UI path slot 'get path' command trigger.
Constructor: | getPathCommand(LEdit, mode = 0, fileTypes = []) |
Return: | None |
Arguments: |
- LEdit
- mode(int) ; [default: 0]
- fileTypes(list) ; [default: []]
|
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: | None |
Arguments: |
|
Keyword Arguments: |
getWindow
Constructor: | getWindow(windowName = "") |
Return: | None |
Arguments: |
- windowName(str) ; [default: ""]
|
Keyword Arguments: |
get_maya_window
Main maya window get for a global UI parent
Constructor: | get_maya_window() |
Return: | None |
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:
1. Nothing is selected - if the field is empty- do nothing, else clear the field.
2. objects are selected, without any CB selection - load the object names in, seperated by commas.
3. 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: | None |
Arguments: |
|
Keyword Arguments: |
optionBoxTextTrigger
Constructor: | optionBoxTextTrigger(comboBox = None, lineWditWidget = None, index = 0) |
Return: | None |
Arguments: |
- comboBox(str) ; [default: None]
- lineWditWidget(str) ; [default: None]
- index(int) ; [default: 0]
|
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: | None |
Arguments: |
- filePath(str) ; [default: ""]
|
Keyword Arguments: |
reloadWindow
Constructor: | reloadWindow(windowName = "") |
Return: | None |
Arguments: |
- windowName(str) ; [default: ""]
|
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: |
setLinkToQLabel
Constructor: | setLinkToQLabel(labelObj = None, ahref = "") |
Return: | None |
Arguments: |
- labelObj(str) ; [default: None]
- ahref(str) ; [default: ""]
|
Keyword Arguments: |
'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: |
- colorOverrideCbx
- sideCB
- ovverideBtnList
- rigTop
- ignoreOvverideCheckbox(bool) ; [default: False]
|
Keyword Arguments: |
tearOffWindow
Create a new maya 'tear-off' panel.
Constructor: | tearOffWindow(name, title, width, height, cameraToView) |
Return: | None |
Arguments: |
- name
- title
- width
- height
- cameraToView
|
Keyword Arguments: |
toQtObject
Convert a maya UI component into a QT object
Constructor: | toQtObject(mayaName, kwargs) |
Return: | None |
Arguments: |
|
Keyword Arguments: |