Widgets¶
Action¶
- class ExtendedQAction(*args: Any, **kwargs: Any)¶
Bases:
QWidgetAction
OptionBox style QAction, mirrors as close as possible to autodesk maya’s QAction
- setOptionBoxIcon(iconPath)¶
- setIcon(iconPath)¶
- createWidget(parent)¶
- class ColorAction(*args: Any, **kwargs: Any)¶
Bases:
QWidgetAction
Dialog¶
Dialogs¶
- getDirectoriesDialog(startingDir)¶
Create a file dialog with zoo themes and multifile selection
Returns a list of paths
- Parameters:
startingDir –
- Returns:
eg [“c:/path/to/folder1”, “c:/path/to/second/folder”]
Dockwidget¶
- class DockWidget(*args: Any, **kwargs: Any)¶
Bases:
QDockWidget
Dpiscaling¶
- class DPIScaling¶
Bases:
object
Used with any QtWidget to add dpiScaling to their methods
- setFixedSize(size)¶
Sets fixed size
- Parameters:
size – Dpiscaling is automatically applied here
- Returns:
- setFixedHeight(height)¶
DpiScaling version of set fixed height
- Parameters:
height –
- Returns:
- setFixedWidth(width)¶
DpiScaling version of set fixed width
- Parameters:
width –
- Returns:
- setMaximumWidth(width)¶
Sets the maximum button size in pixels
- Parameters:
size (QtCore.QSize) – New fixed size of the widget
- setMinimumWidth(width)¶
Sets the minimum button size in pixels
- Parameters:
size (QtCore.QSize) – New fixed size of the widget
- setMaximumHeight(height)¶
Sets the maximum button size in pixels
- Parameters:
size (QtCore.QSize) – New fixed size of the widget
- setMinimumHeight(height)¶
Sets the minimum button size in pixels
- Parameters:
size (QtCore.QSize) – New fixed size of the widget
Elements¶
Expandedtooltip¶
- class ExpandedTooltipPopup(*args: Any, **kwargs: Any)¶
Bases:
Dialog
Expanded tooltips for when we press control (or the key as defined by popupKey). Features richtext labels and animated gifs in a transparent window. ::examples:
To install the tooltip on a PyQt widget:
btn = QtWidgets.QPushButton() toolTip = componentWidgetExpand = { "title": "Expand / Collapse Widget", "icon": "magic", "tooltip": "Expand / Collapse Widget", "expanded": "Expand / Collapse Widget <p><b><i>Everything here can be customized using HTML tags.</i></b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et cursus libero. </p><p>Etiam viverra quam sit amet eros volutpat, ac <span class="highlight"><i>aliquam ligula fringilla</i></span>. In semper volutpat nunc, ac placerat nisi mollis a. Donec condimentum urna eu elementum hendrerit. Sed pellentesque.</p><p> <a href="http://create3dcharacters.com">Click for full documentation</a>" } installTooltips(btn, tooltipDict=toolTip)
The “expanded” attribute allows for rich text:
{"expanded": ''' Expand / Collapse Widget <p><b><i>Everything here can be customized using HTML tags.</i></b></p> <p><span class="highlight">Highlighted text with custom highlight color </span> <p>Gifs can be used as well. <zoo gif="selectAllAnimCurvesInTheScene" /></p> <p> <a href="http://create3dcharacters.com">Click for full documentation</a>"'''}
Gifs folders are set up in the package.json: “HIVE_UI_GIFS”: “{self}/zoo/apps/hiveartistui/gifs”
ExpandedTooltipPopup is just a dialogue box, so instantiate it then move it like a normal window:
# On holding down control the popup (this class) will be displayed. ON Key release it will be closed def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Control: pos = QtGui.QCursor.pos() widgetAt = QtWidgets.QApplication.widgetAt(pos) if expandedtooltip.hasExpandedTooltips(widgetAt): self._popuptooltip = expandedtooltip.ExpandedTooltipPopup(widgetAt, keyRelease=QtCore.Qt.Key_Control) self._popuptooltip.move(QtGui.QCursor.pos()) self.ctrlEvent = True def keyReleaseEvent(self, event): if event.key() == QtCore.Qt.Key_Control: self.ctrlEvent = False
Example Stylesheet:
style = ''' ExpandedTooltipPopup .QFrame {{ border-width: 1px; border-style: solid; border-radius: 3px; border-color: rgba(255,255,255,0.5); background-color: rgba(20,20,20,0.8); }} ExpandedTooltipPopup QLabel {{ border-width: 0px; background: transparent; font-size: 11pt; }} ExpandedTooltipPopup QLabel#title {{ padding: 5px 0px 0px 0px; font-size: 14pt; }} ExpandedTooltipPopup GifWidget {{ border-width: 0px; background: transparent; }} '''
- defaultIcon = 'magic'¶
- ETT_ICONCOLOUR = (82, 133, 166)¶
- ETT_LINKCOLOUR = (255, 255, 255)¶
- ETT_THEMECOLOUR = (82, 133, 166)¶
- initUi()¶
- center()¶
Override the center from parent class and ignore everything.
- setText(text, applyStyle=True)¶
Sets the text for the ExpandedTooltip. It will parse through the text and split it up into Labels and GifWidgets and add it to the layout if need be.
- Parameters:
text –
applyStyle –
- Returns:
- applyStyle(text)¶
Apply our own custom style to the text. A bit hacky but it replaces the text to what we want. Until we figure a way to apply custom classes to the rich text inside labels
class=”link” ====> style=”color:rgb()” class=”highlight” ====> style=”color: rgb{}; font-weight: bold” etc..
- addWidgets(wlist)¶
Adds the list of widgets into our layout
- Parameters:
wlist (list(QtWidgets.QWidget)) –
- clear()¶
Clear all the widgets in the frameLayout
- setIcon(icon)¶
Sets the large icon of this tooltip dialogue window
- Parameters:
icon –
- setTitle(title, applyStyle=True)¶
Set the title text and apply our style by replacing text if we need to.
- Parameters:
title –
applyStyle –
- keyReleaseEvent(event)¶
Close the dialogue on expanded tooltip key release
- Parameters:
event –
- class GifWidget(*args: Any, **kwargs: Any)¶
Bases:
QLabel
A QLabel which plays our gif out
- gifEnv = 'HIVE_UI_GIFS'¶
- class WidgetsFromTextParser(text)¶
Bases:
HTMLParser
Parses an string (with html tags) and splits it up into a list of widgets. This is so we can inject the GifWidgets into the main layout.
The documentation here describes how to use HTMLParser quite well: https://docs.python.org/2/library/htmlparser.html
Pretty much we feed the string into HTMLParser, and we reconstruct it with self.constructed. Once it reaches a <zoo> tag, it creates a new widget for each zoo tag.
- feed(data)¶
Goes through the string and throws out handle events as it comes across tags.
- Parameters:
data –
- widgets()¶
Return the widgets generated from the string that is fed in.
- Returns:
list
- handle_starttag(tag, attrs)¶
Every time it finds a start tag eg. <a>, <img>, <span> this function is run along with the data.
Here we add our own tags eg. <zoo gif=”example” />. Create a label from all the previous text, and create a new GifWidget for this gif
- Parameters:
tag –
attrs –
- handle_data(data)¶
Data in between tags eg. <span>data in between tags</span>
- Parameters:
data –
- addGifWidget(file)¶
Add a GifWidget when gif tag is found
- Parameters:
file –
- addLabelFromConstructed()¶
Add a label with the current text in constructed.
- installTooltips(widget, tooltipDict)¶
Installs the expanded tooltip onto a widget. Works in conjunction with artistui.keyPressEvent() to display a popup (zoo.apps.hiveartistui.views.expandedtooltip.ExpandedTooltipPopup)
- Parameters:
widget (QtWidgets.QWidget or QtWidgets.QAction) –
tooltipDict –
- hasExpandedTooltips(widget)¶
Returns whether the widget has the injected _expandedTooltips_ object present in the widget
- Parameters:
widget –
- copyExpandedTooltips(source, dest)¶
Copy the _expandedTooltips_ from source widget to destination
- Parameters:
source –
dest –
Flowlayout¶
FlowLayout Custom layout that mimics the behaviour of a flow layout (not supported in PyQt by default) @source https://qt.gitorious.org/pyside/pyside-examples/source/060dca8e4b82f301dfb33a7182767eaf8ad3d024:examples/layouts/flowlayout.py Comments added by Jos Balcaen(http://josbalcaen.com/) @date 1/1/2015
- class FlowLayout(*args: Any, **kwargs: Any)¶
Bases:
QLayout
Custom layout that mimics the behaviour of a flow layout
- orientation()¶
- setOrientation(orientation)¶
Set out how the widgets will be laid out. Horizontally or vertically
- Parameters:
orientation (QtCore.Qt.Horizontal or QtCore.Qt.Horizontal) – Orientation of the widgets
- Returns:
- clear()¶
Clear all widgets :return:
- addItem(item)¶
Add an item at the end of the layout. This is automatically called when you do addWidget()
- Parameters:
item (QWidgetItem) –
- addSpacing(spacing)¶
- count()¶
Get the number of items in the this layout
:return (int)
- itemAt(index)¶
Get the item at the given index
:param index (int) :return (QWidgetItem)
- takeAt(index)¶
Remove an item at the given index
:param index (int) :return (None)
- insertWidget(index, widget)¶
Insert a widget at a given index
:param index (int) :param widget (QWidget)
- items()¶
- expandingDirections()¶
This layout grows only in the horizontal dimension or vertical direction depending on current orientation
- hasHeightForWidth()¶
If this layout’s preferred height depends on its width
:return (boolean) Always True
- heightForWidth(width)¶
Get the preferred height a layout item with the given width
:param width (int)
- setGeometry(rect)¶
Set the geometry of this layout
:param rect (QRect)
- allowOverflow(allow)¶
Allows the flow layouts to overflow, rather than go onto the next line
- Parameters:
allow (bool) – True to allow, False to not allow
- Returns:
- sizeHint()¶
Get the preferred size of this layout
:return (QSize) The minimum size
- minimumSize()¶
Get the minimum size of this layout
:return (QSize)
- setSpacingX(spacing)¶
X Spacing for each item
- Parameters:
spacing –
- Returns:
- setSpacingY(spacing)¶
Y Spacing for each item
- Parameters:
spacing –
- Returns:
- doLayout(rect, testOnly)¶
Layout all the items
:param rect (QRect) Rect where in the items have to be laid out :param testOnly (boolean) Do the actual layout
Flowtoolbar¶
- class FlowToolBar(*args: Any, **kwargs: Any)¶
Bases:
QFrame
A tool bar based off the FlowLayout. The buttons will flow from left to right and wrap to the next row if there is no space
flowToolbar = FlowToolBar() flowToolbar.addTool("stream2", name="Tool Button Name", iconColor=(255,255,255)) flowToolbar.addToolMenu("stream2", name="Tool Button Name", actions=[('Menu Item 1', func1),('Menu Item 2', func2)]) def func1(): pass def func2(): pass
- overflowIcon = 'sortDown'¶
- initUi()¶
Initialise flow toolbar ui
- setDebugColors(debug)¶
Set debug colors
- Parameters:
debug –
- Returns:
- setIconSize(size)¶
Set the size of the icons of the tools and toolmenus
- Parameters:
size – DPI scale is automatically calculated here so size does not need it here.
- setIconPadding(padding)¶
Sets the padding for the icons of the tools and the tool menus
- Parameters:
padding –
- overflowMenuActive(active)¶
- setOverflowButtonColor(col)¶
Sets the color for the overflow button
- Parameters:
col –
- Returns:
- setupOverflowMenu(btn=None)¶
Setup the overflow menu and connect it to btn. If there’s no button yet create one.
- Parameters:
btn –
- Returns:
- addToolButton(iconName, name='', iconColor=(255, 255, 255), doubleClickEnabled=False)¶
Creates a new tool button based on the icon name, and the name.
- Parameters:
iconName – Name of the icon to retrieve
name – Name of the tool
iconColor – Color of the icon for the tool
doubleClickEnabled – Enable doubleclick for button
- Returns:
- Return type:
- getIconSize()¶
Returns the icon generated QSize
- Return type:
QtCore.QSize
- addToolMenu(iconName, name, actions, iconColor=(255, 255, 255), showIndicator=True)¶
Adds a new tool menu.
- Parameters:
iconName – Name of the icon to retrieve
name – Name of the tool
actions – Actions is a list of tuples with the name and function to run eg (‘Name’, self.menuItemPressed)
iconColor – The icon color
showIndicator – Show the menu indicator (the arrow in the corner)
- clear()¶
Clear all widgets
- toolsClicked()¶
All buttons will run through here. It will then run a separate function telling which button was pressed, along with some other details
- resizeEvent(event)¶
Resize event for the toolbar
- Parameters:
event –
- Returns:
- sizeHint()¶
Size hint for the flow toolbar
- Returns:
- updateWidgetsOverflow(size=None)¶
Hide or show widgets based on the size of the flow toolbar.
If the flow toolbar is too small it will move widgets it to the overflow menu.
If there are widgets in the overflow menu, place it back into the flow toolbar if there is space.
- Parameters:
size (QtCore.QSize) – new size
- Returns:
- setMenuItemsVisible(texts)¶
Set the texts visible in the menu.
- Parameters:
texts –
- Returns:
- itemList()¶
Itemlist without the overflow menu button
- Returns:
- items()¶
Flow layout items
- Returns:
- buttonClicked(wgt, name)¶
O verridden by the subclass
- Parameters:
wgt – The widget that was pressed, typically a button
name – The name of the tool
- setHeight(height)¶
Set Fixed Height
- Parameters:
height –
- Returns:
- setSpacingX(x)¶
Set spacing of items in layout
- Parameters:
x –
- Returns:
- setSpacingY(y)¶
Set spacing of items in layout
- Parameters:
y –
- Returns:
Frame¶
- class CollapsableFrame(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- initUi()¶
Builds the UI, the title and the collapsable widget that’ the container for self.hiderLayout
- buildTitleFrame()¶
Builds the title part of the layout with a QFrame widget
- addWidget(widget)¶
- addLayout(layout)¶
- buildHiderWidget()¶
Builds widget that is collapsable Widget can be toggled so it’s a container for the layout
- onCollapsed()¶
- onExpand()¶
- showHideWidget(*args)¶
Shows and hides the widget self.widgetHider this contains the layout self.hiderLayout which will hold the custom contents that the user specifies
- connections()¶
Toggle widgetHider vis
- class CollapsableFrameThin(*args: Any, **kwargs: Any)¶
Bases:
CollapsableFrame
- buildTitleFrame()¶
Add custom behaviour to the title frame
- Returns:
Groupbox¶
- class CollapsibleGroupBox(*args: Any, **kwargs: Any)¶
Bases:
QGroupBox
Collapsible Group box using arrow icons to indicate current state.
The size of the expansion is determined by the size of the contents.
- Note:
All standard groupbox features are supported
- resizeGroupBox(fullSize)¶
handles the sizing on toggle
- paintEvent(e)¶
Groupedtreewidget¶
- class TreeWidgetItem(*args: Any, **kwargs: Any)¶
Bases:
QTreeWidgetItem
- class ItemInfo¶
Bases:
object
The description of a TreeWidgetItem so it can be pickled into a mime data and dragged into another tree
- data = None¶
- text = ''¶
- children = None¶
- toolTip = ''¶
- itemHash = 0¶
- itemType = ''¶
- classmethod fromItems(items)¶
If a child is selected after parent, the child is not included in the reconstruction
If a child is selected first, then the parent after, the child excluded in the reconstruction
- Parameters:
items –
- Returns:
- classmethod fromItem(item)¶
Constructs a tree from item
- Parameters:
item –
- Returns:
- classmethod removeFromDescendents(itemInfo, removeInfo)¶
Remove removeInfo from itemInfos descendents
- Parameters:
itemInfo –
removeInfo –
- Returns:
- classmethod removeRedundant(infos)¶
Remove redundant children from list of infos.
When dragging we don’t want the children to be in the list, only the upper most parent. This is to stop it from creating the child already when the parent creates the children when reconstructing the TreeWidgetItem sub tree.
- Parameters:
infos –
- Returns:
- classmethod inDescendents(sourceInfo, targetInfo)¶
If target is in source’s descendants
- Parameters:
sourceInfo (ItemInfo) –
- Returns:
- descendents()¶
Descendants of info
- Returns:
- class GroupedTreeWidget(*args: Any, **kwargs: Any)¶
Bases:
QTreeWidget
- ITEMTYPE_WIDGET = 'WIDGET'¶
- ITEMTYPE_GROUP = 'GROUP'¶
- ITEMWIDGETINFO_COL = 1¶
- DATA_COL = 2¶
- INSERT_AFTERSELECTION = 0¶
- INSERT_END = 1¶
- INSERT_ATINDEX = 2¶
- defaultGroupName = 'Group'¶
- initUi()¶
Init Ui Setup
- Returns:
- dragging()¶
- setDragDropEnabled(state)¶
Enables or disables drag and drop for the tree widget.
- connections()¶
- treeSelectionChanged()¶
- initDragDrop()¶
Set up Drag drop Settings for this widget
- setDragWidget(widget, hotspotAlign=MockExt.QtCore.Qt.AlignVCenter)¶
The widget that will be shown in the drag
- Returns:
- startDrag(supportedActions, widget=None)¶
Override this to set the widget thats gets shown when dragged
Example:
def startDrag(self, supportedActions): itemPos = self.mapFromGlobal(QtGui.QCursor.pos()) item = self.itemAt(itemPos) self.setDragWidget(self.itemWidget(item, groupedtreewidget.WIDGET_COL).titleFrame, hotspotAlign=QtCore.Qt.AlignVCenter) super(ToolsetTreeWidget, self).startDrag(supportedActions)
- Parameters:
supportedActions –
widget – Widget to use to drag. If widget is none, then just use the whole ItemWidget. Usually set by the overriding class
- Returns:
- dragTargetChanged(widget)¶
Drag target changed
- Parameters:
widget –
- Returns:
- Return type:
- dropCancelledCheck(target)¶
Check to see if the drop was cancelled
- Parameters:
target (QtWidgets.QWidget) – The target widget that has been dropped into
- Returns:
- Return type:
- dropEvent(event)¶
Drop event
Handle all the QT weirdness of drag dropping to separate trees here.
- Parameters:
event (QtGui.QDropEvent) –
- Returns:
- removeItems(items)¶
Remove items from tree
- Parameters:
items (list) –
- Returns:
- Return type:
- mimeData(items)¶
The data that will be dragged between tree nodes
- Parameters:
items (list of QtWidgets.TreeWidgetItem) – List of selected TreeWidgetItems
- Returns:
- dropMimeData(parent, index, mimedata, action)¶
Drop Mime Data
This is usually run first before dropEvent
- Parameters:
parent –
index –
mimedata –
action –
- Returns:
- reconstructItems(item, widgetInfo)¶
Reconstruct items from widgetInfo.
Includes the children
- Parameters:
item –
widgetInfo (ItemInfo) –
- Returns:
- updateItemWidgets(items)¶
Update TreeWidgetItems to their respective itemWidgets children.
Usually used when drag and dropped, since drag drop deletes their itemWidget.
- Parameters:
items (list of QtWidgets.QTreeWidgetItem) –
- Returns:
- updateAllWidgets()¶
Update all the TreeWidgetItems to their respective itemWidgets in the tree.
Usually used when drag and dropped, since drag drop deletes their itemWidget.
- Returns:
- dragEnterEvent(event)¶
Only accept if it is the same GroupedTreeWidget type.
Override if you need it to accept drag events even if the tree class is different
- Parameters:
event –
- Returns:
- updateWidget(item)¶
Update the TreeWidgetItem to its itemWidget.
Should be overridden by its subclass
Usually used when drag and dropped, since drag drop deletes their itemWidget. This is to reconstruct the itemWidget.
model = self.itemWidgetInfo(item) self.setItemWidget(item, 0, QtWidgets.QLabel(item.text(1), parent=self))
or
self.setItemWidget(item, WIDGET_COL, componentwidget.ComponentWidget(componentModel=model, parent=self))
- Parameters:
item (QtWidgets.QTreeWidgetItem) –
- Returns:
- updateGroupWidget(item)¶
Update the TreeWidgetItem to use a GroupWidget.
This should be overridden if you have your own GroupWidget
- Parameters:
item (QtWidgets.QTreeWidgetItem) – TreeWidgetItem to attach a GroupWidget to
- Returns:
- hashesFromItemInfo(itemInfos, str=False)¶
Get all the itemHashes from itemInfos and their children
- Parameters:
itemInfos – list of
str –
- Returns:
- itemFromHash(hash, rootItem=None)¶
Get the hash which is saved in the items tooltip
- Parameters:
hash –
rootItem –
- Returns:
- descendants(item)¶
Descendants of QTreeWidgetItem
- Parameters:
item (QtWidgets.QTreeWidgetItem) –
- Returns:
- setCurrentItems(items)¶
Selects the items in the TreeWidget
- Parameters:
items –
- insertNewItem(name, widget=None, index=0, treeParent=None, itemType='WIDGET', widgetInfo=None, icon=None)¶
Inserts a new item at a location, and sets the widget as the itemWidget
ItemType can be Widget or Group. Groups wont have user customized widgets, but can have children. ITEMTYPE_WIDGETS wont have children.
May merge with self.addNewItem()
- Parameters:
name – Name of the new Item, generally put into the text field of the TreeWidgetItem. This is the text that is used for the search bar if it is active.
widget – Expects ItemWidget or any subclass of QtWidgets.QWidget.
index – Index to insert into
treeParent (TreeWidgetItem or None) – The parent that it will insert into. If treeParent is None, it will assume the parent to be Root
itemType – The type of widget being set for the new Item.
icon – Icon to set for the TreeWidgetItem
- Returns:
The new item created
- Return type:
- addNewItem(name, widget=None, itemType='WIDGET', widgetInfo=None, icon=None)¶
Add a new item type. Should be a group or an itemWidget. If you’d like to add a TreeWidgetItem instead, use addNewTreeWidgetItem()
ItemType can be Widget or Group. Groups wont have user customized widgets, but can have children. ITEMTYPE_WIDGETS wont have children.
May merge with self.insertNewItem()
- Parameters:
widgetInfo –
name – Name of the new Item, generally put into the text field of the TreeWidgetItem. This is the text that is used for the search bar if it is active.
widget – Expects ItemWidget or any subclass of QtWidgets.QWidget.
itemType – The type of widget being set for the new Item.
icon – Icon to set for the TreeWidgetItem
- Returns:
The new item created
- Return type:
- itemWidgetInfo(item)¶
Retrieve the information to build the widget from the item.
The info to build the itemWidget from the data that is stored in the data column eg. The ComponentModel for a ComponentWidget, or simply Text for QLabel
It would return the ComponentModel or the Text.
- Parameters:
item –
- Returns:
- itemWidgets(itemType=None, treeItem=None)¶
Gets all widgets in the tree.
includeNones is for when QTreeWidgetItems doesn’t have a itemWidget attached, but for any reason or another we still want to know
- Returns:
List of itemWidgets
- Return type:
list[]
- treeWidgetItemByHash(treeItemHash)¶
Return TreeWidgetItem by hash. If this is slow maybe we should put all the treeWidgetItems in a hash map as well.
- Parameters:
treeItemHash –
- Returns:
- Return type:
TreeWidgetItem or None
- itemWidget(treeItem, col=None)¶
Short hand to get the item widget from the default column (as defined by WIDGET_COL)
- Parameters:
treeItem –
col –
- Returns:
QtWidgets.QWidget
- updateTreeWidget(delay=False)¶
Updates the tree widget so the row heights of the TreeWidgetItems matches what the ComponentWidgets ask for in terms of the sizeHint() asks for
- itemType(treeItem)¶
Get the item type (“COMPONENT” or “GROUP”)
- Parameters:
treeItem (TreeWidgetItem) – The TreeWidgetItem to get the type of
- Returns:
- getItemName(treeItem)¶
- filter(text)¶
Hide anything that that doesnt have text. Used for searches.
- Parameters:
text –
- addGroup(name='', expanded=True, groupSelected=True, groupWgt=None)¶
Adds a group to the ComponentTreeWidget. If no name is given, it will generate a unique one in the form of “Group 1”, “Group 2”, “Group 3” etc
- Parameters:
groupSelected –
expanded –
name –
groupWgt – Use this as the widget, if its none we’ll just use the text background as the display
- Returns:
- Todo:
This area still needs a bit of work. Update with addNewItem code
- insertGroup(name='', index=0, treeParent=None, expanded=True, groupWgt=None, icon=None)¶
Inserts a group into index, underneath treeParent.
- Parameters:
name –
index –
treeParent –
expanded –
groupWgt (zoo.apps.hiveartistui.views.componentwidget.ComponentGroupWidget) –
icon –
- Returns:
- addToGroup(item, group)¶
- getUniqueGroupName()¶
Returns a unique group name: “Group 1”, “Group 2”, “Group 3” etc.
- Returns:
- Return type:
- applyFlags()¶
Apply flags as set by self.groupFlags and self.itemWidgetFlags.
ITEMTYPE_WIDGET gets applied a different set of drag drop flags to ITEMWIDGET_GROUP
- iterator()¶
Iterator to iterate through the treeItems
for it in treeItemIterator: treeItem = it.value()
- Returns:
- Return type:
collections.Iterator[QtWidgets.QTreeWidgetItem]
- class ItemWidgetTitleFrame(*args: Any, **kwargs: Any)¶
Bases:
StackTitleFrame
- initUi()¶
Builds the title part of the layout with a QFrame widget
- class GroupWidget(*args: Any, **kwargs: Any)¶
Bases:
QWidget
The Widget used for groups in TreeWidget
- initUi()¶
- setTreeItem(treeItem)¶
- connections()¶
- updateTreeItemData()¶
- text()¶
Returns the text of the text edit :return:
- buildTitleFrame()¶
Builds the title part of the layout with a QFrame widget
- expandToggle()¶
- onCollapsed()¶
Collapse and hide the item contents :return:
- onExpand()¶
- expand()¶
Extra Code for convenience
- collapse()¶
Extra Code for convenience
- mousePressEvent(event)¶
- passThroughMouseEvent(event)¶
Headertoolbar¶
- class HeaderToolbar(*args: Any, **kwargs: Any)¶
Bases:
QToolBar
Header tool bar for a window, comes prebuilt with a label, minimize,maximize and close buttons, parent must implement showMinimized, toggleMaximized, close
Icon¶
Joinedradio¶
Label¶
- class Label(*args: Any, **kwargs: Any)¶
Bases:
QLabel
,MenuCreateClickMethods
This class adds the capacity for a left/middle/right click menu to be added to a QLabel
Inherits from zoo’s QtWidgets.QLabel and MenuCreateClickMethods
Menus are not added by default they must be set in the ui code. QMenu’s can be passed in via setMenu():
zooQtWidget.setMenu(myQMenu, mouseButton=QtCore.Qt.RightButton)
Recommended to use zoocore_pro’s extendedmenu.ExtendedMenu(). Pass that in instead of a QMenu for extra functionality
See the class docs for MenuCreateClickMethods() for more information
- Parameters:
parent (QWidget) – the parent widget
menuVOffset (int) – The vertical offset (down) menu drawn from widget top corner. DPI is handled
- mousePressEvent(event)¶
mouseClick emit
Checks to see if a menu exists on the current clicked mouse button, if not, use the original Qt behaviour
- Parameters:
event (QEvent) – the mouse pressed event from the QLineEdit
- class LabelDivider(*args: Any, **kwargs: Any)¶
Bases:
QWidget
Builds a label and a divider with options for Bold and Uppercase
- Parameters:
text (str) – The label text
parent (QWidget) – The parent widget
margins (tuple(int)) – Margins of the layout in pixels DPI handled, (right, top, left, bottom)
spacing (int) – The spacing in pixels between widgets DPI handled
bold (bool) – Make the label bold if True
upper (bool) – Make the label all uppercase if True
- class LabelDividerCheckBox(*args: Any, **kwargs: Any)¶
Bases:
LabelDivider
- class IconLabel(*args: Any, **kwargs: Any)¶
Bases:
QWidget
Widget which contains a horizontal layout with an icon and a label
- class TitleLabel(*args: Any, **kwargs: Any)¶
Bases:
QLabel
For CSS Purposes
Layouts¶
- class GridLayout(*args: Any, **kwargs: Any)¶
Bases:
QGridLayout
- hBoxLayout(parent=None, margins=(0, 0, 0, 0), spacing=6)¶
One liner for QtWidgets.QHBoxLayout() to make it easier to create an easy Horizontal Box layout DPI (4k) is handled here Defaults use regular spacing and no margins
- Parameters:
parent (
QtWidgets.QVBoxLayout
) – The parent widget for the layoutmargins (tuple) – override the margins with this value (left, top, right, bottom)
spacing (int) – override the spacing with this pixel value
- Return type:
QtWidgets.QHBoxLayout
- vBoxLayout(parent=None, margins=(0, 0, 0, 0), spacing=6)¶
One liner for QtWidgets.QVBoxLayout() to make it easier to create an easy Vertical Box layout DPI (4k) is handled here Defaults use regular spacing and no margins
- Parameters:
parent (
QtWidgets.QVBoxLayout
) – The parent widget for the layoutmargins (tuple) – override the margins with this value (left, top, right, bottom)
spacing (int) – override the spacing with this pixel value
- Return type:
QtWidgets.QVBoxLayout
- vGraphicsLinearLayout(parent=None, margins=(0, 0, 0, 0), spacing=0, orientation=MockExt.QtCore.Qt.Vertical)¶
- hGraphicsLinearLayout(parent=None, margins=(0, 0, 0, 0), spacing=0, orientation=MockExt.QtCore.Qt.Horizontal)¶
- formLayout(parent=None, margins=(0, 0, 0, 0), spacing=6)¶
Listview¶
- class ListView(*args: Any, **kwargs: Any)¶
Bases:
QListView
- contextMenuRequested¶
alias of
list
- setSupportsRightClick(state)¶
Sets whether this list view should support a right click context menu.
- Parameters:
state (bool) – If True then A right click menu will be created and contextMenuRequested signal will be emitted.
- closestIndex(pos)¶
Get the closest index based on pos
- Parameters:
pos (
QtCore.QPoint
) –- Returns:
- Return type:
QtCore.QModelIndex
- visibleIndices(pre=0, post=0)¶
Gets visible items
Set extra to 1 or more if you want extra indices at the beginning and at the end. It will only return valid indices.
Logoutput¶
- shiftColor(c1, c1Strength, c2, c2Strength)¶
- class OutputLogDialog(*args: Any, **kwargs: Any)¶
Bases:
QPlainTextEdit
Output text edit
- ::example:
wid = OutputLogDialog(“MyLogWindow”) wid.show() wid.logInfo(“helloworld”) wid.logDebug(“helloworld”) wid.logWarning(“helloworld”) wid.logError(“helloworld”) wid.logCritical(“helloworld”)
- debugColor = '#f4f4f4'¶
- warningColor = '#ffe700'¶
- errorColor = '#CC0000'¶
- criticalColor = '#CC0000'¶
- createLayout()¶
Sets up the layout for the dialog.
- logInfo(msg)¶
- logDebug(msg)¶
- logWarning(msg)¶
- logError(msg)¶
- logCritical(msg)¶
- keyEvent(event)¶
- write(msg, color=MockExt.QtGui.QColor)¶
- factoryLog(msg, level)¶
- wheelEvent(event)¶
Handles zoom in/out of the text.
- zoom(direction)¶
Zoom in on the text.
- class QWidgetHandler¶
Bases:
Handler
Custom Qt Logging Handler for Sending Messages to child Widgets
- addWidget(widget)¶
- removeWidget(widget)¶
- clearWidgets()¶
- emit(record)¶
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
Mainwindow¶
- class MainWindow(*args: Any, **kwargs: Any)¶
Bases:
QMainWindow
- restoreWindowSize = False¶
- center()¶
Centers to center of desktop
- Returns:
- window()¶
- Returns:
- Return type:
- addCustomStatusBar()¶
- setupMenuBar()¶
- setCustomCentralWidget(widget)¶
- createDock(mainWidget, area=MockExt.QtCore.Qt.LeftDockWidgetArea, tabify=True)¶
- addDockWidget(area, dockWidget, orientation=MockExt.QtCore.Qt.Horizontal, tabify=True)¶
Adds a dock widget to the current window at the specified location, if the location already has a
- Parameters:
area – QtCore.Qt.DockWidgetArea
dockWidget – QtWidgets.QDockWidget
orientation – QtCore.Qt.Orientation
- findDock(dockName)¶
Returns the dock widget based on the object name passed in as the argument
- Parameters:
dockName – str, the objectName to find, docks must be
- Returns:
QDockWidget
- toggleMaximized()¶
Toggles the maximized window state
- Returns:
- closeEvent(ev)¶
Saves the window state on the close event
- Parameters:
ev –
- Returns:
- reapplySettings()¶
Read window attributes from settings,
using current attributes as defaults (if settings not exist.)
Called at QMainWindow initialization, before show().
- Returns:
- helpAbout(copyrightDate, about, version=1.0)¶
This is a helper method for easily adding a generic help messageBox to self Creates an about MessageBox :param copyrightDate : string , the copyright date for the tool :param about : string, the about information
Messagebox¶
Overlay¶
- class OverlayWidget(*args: Any, **kwargs: Any)¶
Bases:
Dialog
- pressed = False¶
- initUi()¶
- setDebugMode(debug)¶
Debug mode to show where the dialog window is. Turns the window a transparent red
- Parameters:
debug (bool) –
- Returns:
- Return type:
- update()¶
Update geometry to match the parents geometry
- Returns:
- mousePressEvent(event)¶
Send events back down to parent
- Parameters:
event –
- Returns:
- enterEvent(event)¶
On mouse enter, check if it is pressed
- Parameters:
event –
- Returns:
- mouseMoveEvent(event)¶
Send events back down to parent
- Parameters:
event –
- Returns:
- keyReleaseEvent(event)¶
- mouseReleaseEvent(event)¶
Send events back down to parent
- Parameters:
event –
- Returns:
- show(*args, **kwargs)¶
Pathwidget¶
- class DirectoryPathListWidget(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- addPathClicked(path=None)¶
Add path clicked button
- Parameters:
path –
- Returns:
- paths()¶
Return all the paths from the widgets
- Returns:
- clear(emit=True)¶
Clear out the widgets and paths
- Returns:
- class PathWidget(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- setSearchFilter(searchFilter)¶
- path()¶
- Returns:
- alias()¶
- Returns:
- openPathFolder()¶
Opens an os window for browsing files on disk in the users operating system
- onPathBrowseClicked()¶
Browse button clicked
- Returns:
- setPathText(path)¶
Set the path text. Also generate an edit if need be
- Parameters:
path –
- Returns:
- setAliasText(alias)¶
- class PathOpenWidget(*args: Any, **kwargs: Any)¶
Bases:
PathWidget
- onPathBrowseClicked()¶
Browse button clicked
- Returns:
- class DirectoryPathWidget(*args: Any, **kwargs: Any)¶
Bases:
PathWidget
- onPathBrowseClicked()¶
Browse button clicked
- Returns:
- class DirectoryPathRemoveWidget(*args: Any, **kwargs: Any)¶
Bases:
DirectoryPathWidget
- class BrowserPathListWidget(*args: Any, **kwargs: Any)¶
Bases:
DirectoryPathListWidget
- data()¶
- Returns:
- Return type:
list[DirectoryPath]
- factoryResetClicked()¶
- addByDirectoryPath(directoryPath)¶
- Parameters:
directoryPath (
zoo.core.tooldata.tooldata.DirectoryPath
) –- Returns:
- addPath(path=None, alias=None)¶
- Parameters:
path –
alias –
- Returns:
- Return type:
- class BrowserPathWidget(*args: Any, **kwargs: Any)¶
Bases:
DirectoryPathRemoveWidget
- setData(directoryPath)¶
- Parameters:
directoryPath (
zoo.core.tooldata.tooldata.DirectoryPath
) –- Returns:
- data()¶
- Returns:
- Return type:
Popups¶
- FileDialog_directory(windowName='', parent=None, defaultPath='')¶
simple function for QFileDialog.getExistingDirectory, a window popup that searches for a directory
Browses for a directory with a fileDialog window and returns the selected directory
- generateName(name)¶
Generate name
- Parameters:
name –
- Returns:
- class MessageBoxBase(*args: Any, **kwargs: Any)¶
Bases:
ZooWindowThin
- Warning = 'Warning'¶
- Question = 'Question'¶
- Info = 'Info'¶
- Critical = 'Critical'¶
- NoIcon = 'NoIcon'¶
- okIcon = 'checkMark'¶
- cancelIcon = 'xCircleMark'¶
- keyPressEvent(event)¶
keyPress event
- Parameters:
event –
- Returns:
- classmethod calcLabelHeight(text, label)¶
- Parameters:
text –
label (QtWidgets.QLabel) –
- Returns:
- Return type:
- classmethod horizontalAdvance(fm, c)¶
Horizontal advance doesn’t exist in 2018. eg older versions of PySide2
- Parameters:
fm –
c –
- Returns:
- close(result=None)¶
Close window
- Returns:
- Return type:
- class MessageBox(*args: Any, **kwargs: Any)¶
Bases:
MessageBoxBase
- classmethod showQuestion(parent=None, title='', message='', buttonA='Continue', buttonB='Cancel', buttonC=None, buttonIconA='checkMark', buttonIconB='xCircleMark', buttonIconC=None, icon='Question', default=0)¶
- classmethod showWarning(parent=None, title='', message='', buttonA='OK', buttonB='Cancel', buttonC=None, icon='Warning', default=0)¶
- classmethod showCritical(parent=None, title='', message='', buttonA='OK', buttonB='Cancel', buttonC=None, icon='Critical', default=0)¶
- classmethod showOK(title='Confirm', parent=None, message='Proceed', icon='Question', default=0, buttonA='OK', buttonB='Cancel', buttonC=None)¶
Simple function for ok/cancel QMessageBox.question, a window popup that with ok/cancel buttons
- classmethod showSave(title='Confirm', parent=None, message='Proceed?', showDiscard=True, default=0)¶
Simple function for save/don’t save/cancel QMessageBox.question, a window popup with buttons
Can have two or three buttons:
showDiscard True: Save, Discard, Cancel showDiscard False: Save, Cancel
- classmethod showMultiChoice(title='Confirm', parent=None, message='Proceed?', choices=None, showDiscard=False, default=0, buttonB='Discard', buttonC='Cancel')¶
A message box with multiple choice. Also has ok, cancel buttons.
- MessageBox.showMultiChoice( title=”Existing shader found”,
message=”Shader with the name name ‘{}’ found.”.format(shader), choices=[“Replace Shader”,”Assign Existing”, “Create New Shader”], buttonB=”Cancel”)
- Can have the following return results:
# (0, “Replace Shader”) # (1, “Assign Existing”) # (2, “Create New Shader”) # (-1, “cancel”)
Can have two or three buttons:
showDiscard True: Save, Discard, Cancel showDiscard False: Save, Cancel
- classmethod showCombo(title='Confirm', parent=None, message='Proceed?', items=None, data=None, icon=None, defaultItem=None, showDiscard=False, default=0, buttonA='OK', buttonB='Discard', buttonC='Cancel', buttonIconA='checkMark', buttonIconB='xCircleMark', buttonIconC=None)¶
A message box with multiple choice. Also has ok, cancel buttons.
- MessageBox.showCombo( title=”Existing shader found”,
message=”Shader with the name name ‘{}’ found.”.format(shader), items=[“Replace Shader”,”Assign Existing”, “Create New Shader”], buttonB=”Cancel”)
- Can have the following return results:
# (0, “Replace Shader”, <object>) # (1, “Assign Existing”, <object>) # (2, “Create New Shader”, <object>) # (-1, “cancel”, <object>)
Where object is an element from data
Can have two or three buttons:
showDiscard True: Save, Discard, Cancel showDiscard False: Save, Cancel
- classmethod showCustom(customWidget, title='Confirm', parent=None, message='Proceed', icon='Question', default=0, buttonA='OK', buttonB='Cancel', buttonC=None)¶
Simple function for ok/cancel QMessageBox.question, a window popup that with ok/cancel buttons
- classmethod inputDialog(parent=None, title='Input', message='Input:', text='', buttonA='OK', buttonB='Cancel', buttonC=None, buttonIconC=None, icon=None)¶
Show the input dialog
- Parameters:
parent –
title –
message –
buttonA –
buttonB –
text –
icon –
- Returns:
Returns None if cancelled.
- class InputDialog(*args: Any, **kwargs: Any)¶
Bases:
MessageBoxBase
- inputText()¶
Get the input text
- Returns:
- class ComboDialog(*args: Any, **kwargs: Any)¶
Bases:
MessageBoxBase
- selectedItem()¶
Get the choice
- Returns:
- selectedData()¶
- class CustomDialog(*args: Any, **kwargs: Any)¶
Bases:
MessageBoxBase
- class MultiChoiceDialog(*args: Any, **kwargs: Any)¶
Bases:
MessageBoxBase
- choice()¶
Get the choice
- Returns:
- class MessageBoxQt¶
Bases:
object
- classmethod showQuestion(parent, windowName, message, buttonA='Continue', buttonB='Cancel', buttonC=None, icon='Question')¶
Simple function for a dialog window with two or three buttons with changeable button names.
buttonC=None will not show the third button.
Icons are “NoIcon”, “Warning”, “Question”, “Information” or “Critical”
Returns strings “A”, “B” or “C” depending on the button pressed.
- Parameters:
parent (object) – The parent widget, can leave as None and will parent to Maya
windowName (str) – The name title of the window
message (str) – The message/question as presented to the user inside the window
buttonA (str) – The string name of the first button
buttonB (str) – The string name of the second button
buttonC (str) – The string name of the third (optional) button, if None is ignored
- Return buttonPressed:
The button pressed, either “A”, “B” or “C”
- Rtype buttonPressed:
str
- classmethod showOK(windowName='Confirm', parent=None, message='Proceed?', okButton=MockExt.QtWidgets.QMessageBox.Ok)¶
Simple function for ok/cancel QMessageBox.question, a window popup that with ok/cancel buttons
- classmethod showSave(windowName='Confirm', parent=None, message='Proceed?', showDiscard=True)¶
Simple function for save/don’t save/cancel QMessageBox.question, a window popup with buttons
Can have two or three buttons:
showDiscard True: Save, Discard, Cancel showDiscard False: Save, Cancel
- InputDialogQt(windowName='Add Name', textValue='', parent=None, message='Rename?', windowWidth=270, windowHeight=100)¶
Opens a simple QT window that locks the program asking the user to input a string into a text box
Useful for renaming etc.
- SaveDialog(directory, fileExtension='', nameFilters='', parent=None)¶
Opens a Qt save window with options for saving a file.
Returns the path of the file to be created, or “” if the cancel button was clicked.
Also see MessageBox.showSave() which has the option for saving the current scene. With save, cancel or discard.
- Parameters:
- Returns:
The fullPath of the file to be saved, else “” if cancelled.
- Return type:
Resizerwidget¶
- class ResizerWidget(*args: Any, **kwargs: Any)¶
Bases:
QFrame
,DPIScaling
A Layout widget which allows you to flexibly hide widgets.
- LeftToRight = 1¶
- RightToLeft = -1¶
- TopToBottom = 2¶
- BottomToTop = -2¶
- Parallel = 1¶
- Reverse = -1¶
- Inwards = 0¶
- Outwards = 1¶
- RightPad = 1¶
- Open = 0¶
- Closed = 1¶
- setLayoutDirection(direction)¶
Layout Direction of the added widgets
- Parameters:
direction (ResizerWidget.LeftToRight or ResizerWidget.RightToLeft or ResizerWidget.TopToBottom or ResizerWidget.BottomToTop) – The direction of the widgets
- Returns:
- addWidget(wgt, target=True, external=False, defaultHidden=False, initialSize=None)¶
Add a widget to the ResizerWidget layout.
- Parameters:
wgt (QtWidgets.QWidget) – The widget to add
target – Set the wgt as a target for the button to attach itself to. True on default
external (bool) – If the widget is an external widget or not. This allows for behaviours that may require a widget that is outside of the ResizerWidget (in a separate QSplitter for instance)
defaultHidden (bool) – If the widget starts off hidden,
initialSize – Initial size, if none it will use the objects sizeHint
- Returns:
- setTarget(target)¶
Set the target widget that the arrow button will attach itself to
- Parameters:
target (QtWidgets.QWidget) –
- Returns:
- setButtonAlign(align)¶
- Parameters:
align –
- Returns:
- setButtonOffset(offset)¶
The button offset from the aligned position
- Parameters:
offset (QtCore.QPoint) – The button offset
- Returns:
- setFixedWidth(width)¶
DpiScaling version of set fixed width
- Parameters:
width –
- Returns:
- setCollapseDirection(collapseDirection)¶
Set the collapse direction of how the widgets will be hidden when toggled.
The way the widgets collapse on ResizerButton clicked can be set with init() param collapseDirection or setCollapseDirection(). It takes ResizerWidget.Parallel or Reverse. Reverse means widgets will hide from the last widget first. Parallel means the widget will hide in the order they are added.
- Parameters:
collapseDirection (ResizerWidget.Parallel or ResizerWidget.Reverse) – Collapse direction
- Returns:
- target()¶
The resizer button target. The target is what the button is attached to.
- Returns:
- Return type:
QtWidgets.QWidget
- setWidgetVisible(wgt, visible, resize=True, force=False)¶
Set the widget visibility. Also set any settings plus resize the window if need be.
- Parameters:
wgt (QtWidgets.QWidget) – Wgt to resize
visible (bool) – Widget visibility
resize (bool) – Resize the window
force (bool) – Force visibility set. It will usually just pass through if you try to set the visibility off and it is already invisible. But there are cases where you need it to set the settings or resize.
- Returns:
- toggleWidget(widget=None)¶
Toggles the widget and resizes the window
- Parameters:
widget – List of widgets to toggle
- Returns:
- hideAllWidgets()¶
- showAllWidgets(ignoreDefaultHidden=False)¶
Show all the widgets in the ResizerWidget
- Parameters:
ignoreDefaultHidden (bool) – Ignore default hidden widgets and show everything
- Returns:
- widgets()¶
Returns the widgets reversed depending on direction
- Returns:
- Return type:
- setArrowDirectionFromLayout(flip=False)¶
Set Arrow direction based on layout direction and if the window opens outwards or inwards
- Returns:
- edgeToCollapse()¶
Get the edge to collapse based on the collapseDirection and the layout direction
todo: maybe we should have a function for each condition? def isLeftToRightLayout(self): *
- Returns:
- widgetsHidden()¶
Return true if ALL widgets are hidden, false otherwise
- Returns:
- setWindowGeometry(geo, wgt=None)¶
Set the window Geometry
Plus any other resizes that we need to do after
- Parameters:
geo – New window geo
wgt – handle to the widget that might need updating
initial –
- Returns:
- restoreSplitterPositions(splitter, positions, exclude=-1)¶
Restore splitter positions based on a list of positions
- updateButtonPosition()¶
Update button position
- Returns:
- resizeEvent(*args, **kwargs)¶
Update the ResizerButton position on resize
- Parameters:
args –
kwargs –
- Returns:
- class ResizerButton(*args: Any, **kwargs: Any)¶
Bases:
FloatingButton
- arrowColor = (0, 0, 0)¶
- setOffsetPos(offsets)¶
- setTarget(target)¶
Set target to attach itself to
- Parameters:
target (QtWidgets.QWidget) – Target widget
- Returns:
- initUi()¶
Init Ui
- Returns:
- initIcons()¶
Initialize icons by setting icon size
- Returns:
- setAlignmentPosition(align)¶
Sets the positional alignment of the resizer button.
eg QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop
- Parameters:
align – The positional alignment the resizer button in comparison to the parent.
- Returns:
- setArrowDirection(direction)¶
Set the icon arrow direction
- Parameters:
direction (QtCore.Qt.LeftArrow | QtCore.Qt.RightArrow | QtCore.Qt.UpArrow | QtCore.Qt.DownArrow) – Direction to set the arrow to
- Returns:
- setIconSize(iconSize)¶
Set Icon size of the arrow
- Parameters:
iconSize –
- Returns:
- flipArrowDirection()¶
Flip the visual arrow direction
- Returns:
- setRoundedEdge(edge)¶
Set edge that will be rounded
- Parameters:
edge (QtCore.Qt.LeftEdge | QtCore.Qt.TopEdge | QtCore.Qt.RightEdge | QtCore.Qt.BottomEdge) – QtCore.Qt.LeftEdge, QtCore.Qt.TopEdge, QtCore.Qt.RightEdge,QtCore.Qt.BottomEdge
- Returns:
- resize(width, height)¶
- setStyle()¶
Round the edges with Stylesheets
- Returns:
- updateTheme(event)¶
Update the theme
- Returns:
- Return type:
- updatePosition()¶
Update position of button based on target and alignment
- Returns:
Screengrabber¶
qt based screen grab transparent dialog, main mission here to allow the client to select a section of their screen using a rectangle which can be saved to a image file of their choosing.
Searchwidget¶
- class ClearToolButton(*args: Any, **kwargs: Any)¶
Bases:
QToolButton
For css purposes only
- class SearchToolButton(*args: Any, **kwargs: Any)¶
Bases:
QToolButton
For css purposes only
- class SearchLineEdit(*args: Any, **kwargs: Any)¶
Bases:
QLineEdit
,DPIScaling
Search Widget with two icons one on either side, inherits from QLineEdit
- Parameters:
searchPixmap –
clearPixmap –
parent –
iconsEnabled –
- initUi()¶
Init UI
- Returns:
- Return type:
- focusInEvent(event)¶
- Parameters:
event (Qt.QtGui.QFocusEvent) –
- Returns:
- Return type:
- setBackgroundColor(col)¶
- setIconsEnabled(enabled)¶
- updateTheme(event)¶
Update the theme
- Returns:
- Return type:
- updateStyleSheet()¶
- resizeEvent(event)¶
- updateCloseButton(text)¶
Slider¶
- class Slider(*args: Any, **kwargs: Any)¶
Bases:
QSlider
- initUi()¶
Init ui
- Returns:
- Return type:
- updateSliderAccuracy()¶
Set the slider accuracy if int
- Returns:
- Return type:
- enterEvent(event)¶
- styleLeaveCheck()¶
Hide the sub-page when value is 0 since it doesn’t get hidden
- sliderActive()¶
- leaveEvent(event)¶
- value()¶
Sliders are in ints so do the math to figure the correct user value and return the expected float
Internally the slider is an int in the range of 0 - self.sliderAccuracy (int) Convert this to a float value within the correct self.floatMax - self.floatMin
Overridden method
- Return floatValue:
The value of the slider as a float the user expects, not slider raw value which is an int
- Rtype floatValue:
float
- setValue(floatValue)¶
Sets the value of a slider as a float in a user friendly value. Value range self.floatMax - self.floatMin
Overridden method
- Parameters:
floatValue (float) – The value the user will user, in range of self.floatMin - self.floatMax
- setSliderPosition(floatValue)¶
Pass in a float value within the range self.floatMax - self.floatMin
Convert it to the int which the Qt slider expects within 0 - self.sliderAccuracy (int)
Overridden method
- setMinimum(minValue)¶
Sets the minimum value of the slider as a float that the user expects Overridden method
- Parameters:
minValue (float) – The minimum value of the slider as the user expects in float range
- setMaximum(maxValue)¶
Sets the maximum value of the slider as a float that the user expects Overridden method
- Parameters:
maxValue (float) – The maximum value of the slider as the user expects in float range
- setRange(minValue, maxValue)¶
Sets the minimum and maximum range of the slider with float values that the user expects Qt sliders use integers and so this needs to be converted.
Overridden method
- setSuperRange(minValue, maxValue)¶
- class NumSlider(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- initUi()¶
To be overridden
- Returns:
- Return type:
- updateRanges(value)¶
Update ranges based on the value, if dynamicMax or dynamicMin is True
- Parameters:
value –
- Returns:
- Return type:
- blockSignals(state)¶
Blocks the widget
- Parameters:
state (bool) – True will block signals to the widget
- setDisabled(state)¶
Disables or enables the widget/s
- Parameters:
state (bool) – If True will disable, if False will enable
- value()¶
Gets the current value of the slider as a float
- setValue(value)¶
Sets the current slider and text box value with a float, quiet no emits
- Parameters:
value (float) – The value to set the slider and lineEdit to
- text()¶
Gets the current value of the slider as a float
- setText(text)¶
Gets the current value of the slider as a float
- setLabel(labelName)¶
Changes the label text
- label()¶
Gets the label text (name)
- Return labelText:
The name of the label
- Rtype labelText:
str
- uiConnections()¶
Sliderspinbox¶
Slidingwidget¶
- class SlidingWidget(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- setSlidingActive(state)¶
- clearedFocus()¶
- setTimeoutActive(active)¶
- setSlideDirection(direction=MockExt.QtCore.Qt.RightToLeft)¶
- Parameters:
direction (QtCore.Qt.RightToLeft or QtCore.Qt.LeftToRight) –
- Returns:
- setDuration(duration)¶
Duration of animation
- Parameters:
duration (int) – Time in milliseconds
- Returns:
- setWidgets(primary, secondary)¶
Set the widgets of the primary and secondary widget
- Parameters:
primary (QtWidgets.QWidget) – Primary widget is the one that will expand when clicked.
secondary (QtWidgets.QWidget) – Secondary will be be hidden when primary widget is focused
- Returns:
- widgetKeyPressEvent(event)¶
- updateInitial()¶
Set up the initial stretch
- Returns:
- setSlideStretch(value)¶
Set the stretch for the mainlayout widgets.
Usually used in the QPropertyAnimation
- Parameters:
value –
- Returns:
- getSlideStretch()¶
The current slide stretch
- Returns:
- widgetFocusIn(event)¶
Expand the primary widget event
- Parameters:
event (Qt.QtGui.QFocusEvent) –
- Returns:
- widgetFocusOut(event=None)¶
Collapse the primary widget event
- Parameters:
event –
- Returns:
- animate(expand=True)¶
Animate the sliding of the widget
- Parameters:
expand –
- Returns:
Spacer¶
- class Divider(*args: Any, **kwargs: Any)¶
Bases:
QLabel
- class QHLine(*args: Any, **kwargs: Any)¶
Bases:
QFrame
- class QVLine(*args: Any, **kwargs: Any)¶
Bases:
QFrame
- Spacer(width, height, hMin=MockExt.QtWidgets.QSizePolicy.Minimum, vMin=MockExt.QtWidgets.QSizePolicy.Minimum)¶
creates an expanding spacer (empty area) with easy options. DPI auto handled
Size Policies are https://srinikom.github.io/pyside-docs/PySide/QtGui/QSizePolicy.html#PySide.QtGui.PySide.QtGui.QSizePolicy.Policy #. QtWidgets.QSizePolicy.Fixed - never grows or shrinks #. QtWidgets.QSizePolicy.Minimum - no advantage being larger #. QtWidgets.QSizePolicy.Maximum - no advantage being smaller #. QtWidgets.QSizePolicy.Preferred - The sizeHint() is best, but the widget can be shrunk/expanded #. QtWidgets.QSizePolicy.Expanding - but the widget can be shrunk or make use of extra space #. QtWidgets.QSizePolicy.MinimumExpanding - The sizeHint() is minimal, and sufficient #. QtWidgets.QSizePolicy.Ignored - The sizeHint() is ignored. Will get as much space as possible
- Parameters:
- Return spacerItem:
item returned, ie the spacerItem
- Rtype spacerItem:
object
Spinner¶
- class Spinner(*args: Any, **kwargs: Any)¶
Bases:
QWidget
Classic widget which spins in a circle, useful for when loading operations happen
- paintEvent(event)¶
- showEvent(event)¶
Called when the widget is being shown
- hideEvent(event)¶
Called when the widget is being hidden
- closeEvent(event)¶
Called when the widget is being closed - ensures the timer is stopped to avoid unnecessary painting
- onTimerOut()¶
Triggered when the timer times out and used to trigger a repaint of the widget.
Stackwidget¶
- class StackWidget(*args: Any, **kwargs: Any)¶
Bases:
QWidget
The overall layout widget. The table underneath (self.stackTableWgt) holds all the stack items.
StackWidget is the overall view, StackTableWidget is the actual widget that holds the StackItems themselves.
- initUi()¶
- connections()¶
Connections for the buttons and the search edit :return:
- collapseClicked()¶
Collapse all the StackItems in the Table
- expandClicked()¶
Expand all the StackItems in the Table
- onStackSearchChanged()¶
Filter the results based on the text inputted into the search bar
- clearStack()¶
Clear all the items in the stack
- addStackItem(item)¶
Add item to the StackTableWidget
- Parameters:
item – StackItem to add to the table
- replaceStackItems(items)¶
Clear all items and replace it with the items
- Parameters:
items – List of items to add to the stack table
- clearSearchEdit()¶
Clear the search bar
- shiftItem(wgt, dir)¶
Shift the item up or down in the table
- Parameters:
wgt – The StackItem to shift
dir – The direction to shift -1 is upwards, 1 is downwards
- deleteItem(wgt)¶
Delete the stack item from the table
- Parameters:
wgt –
- class StackTableWidget(*args: Any, **kwargs: Any)¶
Bases:
QTableWidget
The Table with the actual stack and items. Maybe should merge with StackWidget
- initUi()¶
- shiftTableItem(wgt, dir)¶
- collapseAll()¶
- expandAll()¶
- deleteTableItem(wgt)¶
- addStackItem(item)¶
- addRow(stackItem)¶
- getRow(stackItem)¶
- filter(text)¶
- getStackItems()¶
- updateSize(widget=None)¶
Updates the size based on the widget who sent the request. Can be forced by setting the widget parameter
- Parameters:
widget – None or
QtWidgets.QWidget
- clearStack()¶
- sceneRefresh()¶
- class StackItem(*args: Any, **kwargs: Any)¶
Bases:
QFrame
- setArrowsVisible(visible)¶
Set the shift arrows to be visible or not. These arrows allow the StackItem to be shifted upwards or downwards.
- Parameters:
visible – bool
- property contentsLayout¶
- titleTextWidget()¶
- showExpandIndicator(vis)¶
- setTitleTextMouseTransparent(trans)¶
- initUi()¶
- setItemIconColor(col)¶
- setItemIcon(name)¶
- shiftUp()¶
- shiftDown()¶
- addWidget(widget)¶
- addLayout(layout)¶
- buildHiderWidget()¶
Builds widget that is collapsable Widget can be toggled so it’s a container for the layout
- onCollapsed(emit=True)¶
Collapse and hide the item contents
- onExpand(emit=True)¶
Expand the contents and show all the widget data
- expand(emit=True)¶
Extra Code for convenience
- collapse(emit=True)¶
Extra Code for convenience
- toggleContents(emit=True)¶
Shows and hides the widget self.widgetHider this contains the layout self.hiderLayout which will hold the custom contents that the user specifies
- setComboToText(combobox, text)¶
Find the text in the combobox and sets it to active.
- Parameters:
combobox –
text (str) –
- updateSize()¶
Update the size of the widget. Usually called by collapse or expand for when the widget contents are hidden or shown.
- getTitle()¶
Get method for the title text
- setTitle(text)¶
Set method to get the title text
- Parameters:
text –
- setFrameColor(color)¶
- connections()¶
- class StackTitleFrame(*args: Any, **kwargs: Any)¶
Bases:
QFrame
,DPIScaling
- mouseDoubleClickEvent(event)¶
- shiftUp()¶
- shiftDown()¶
- initUi()¶
Builds the title part of the layout with a QFrame widget
- setDeleteButtonIcon(name)¶
- collapse()¶
- expand()¶
- connections()¶
Connections for stack items
- selectCheck()¶
Stops any selection from happening if title is not editable
- Returns:
- Return type:
- titleValidate()¶
Removes invalid characters and replaces spaces with underscores
- setItemIconColor(col)¶
- setItemIcon(name)¶
Stringedit¶
- class StringEdit(*args: Any, **kwargs: Any)¶
Bases:
QWidget
- property textModified¶
Maya style update, on return and switching out of the text box use for GUIs
- Returns:
- property editingFinished¶
- property textChanged¶
- property returnPressed¶
- property mousePressed¶
- property mouseMoved¶
- property mouseReleased¶
- connections()¶
Connects the buttons and text changed emit
- Returns:
- Return type:
- text()¶
Get the text from the edit
- Returns:
- selectAll()¶
Select all in the edit
- Returns:
- Return type:
- setValue(value)¶
Set the value
- Parameters:
value –
- Returns:
- Return type:
- value()¶
Get the edit value
- Returns:
- Return type:
- setDisabled(state)¶
Disable the text (make it grey)
- setText(value)¶
Change the text at any time
- setLabel(label)¶
Set the text for the label widget
- setFocus()¶
Set the focus of the edit
- Returns:
- Return type:
- setLabelFixedWidth(width)¶
Set the fixed width of the label
- setTxtFixedWidth(width)¶
Set the fixed width of the lineEdit
- clearFocus()¶
Clear the focus of the edit
- Returns:
- Return type:
- blockSignals(b)¶
Block signals properly
- Parameters:
b –
- Returns:
- Return type:
- setValidator(v)¶
Set validator
- Parameters:
v (Qt.QtGui.QValidator) –
- Returns:
- Return type:
- update(*args, **kwargs)¶
- setMenu(menu, modeList=None, mouseButton=MockExt.QtCore.Qt.RightButton)¶
Add the left/middle/right click menu by passing in a QMenu
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))) – 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
- addActionList(modes, mouseButton=MockExt.QtCore.Qt.RightButton)¶
resets the appropriate mouse click menu with the incoming modes
modeList: [(“icon1”, “menuName1”), (“icon2”, “menuName2”), (“icon3”, “menuName3”)]
resets the lists and menus:
self.menuiconstantsonList: [“icon1”, “icon2”, “icon3”] self.menuiconstantsonList: [“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 IntEdit(*args: Any, **kwargs: Any)¶
Bases:
StringEdit
- setMinValue(val)¶
Set Min Value
- Parameters:
val –
- Returns:
- Return type:
- setMaxValue(val)¶
Set Max Value
- Parameters:
val –
- Returns:
- Return type:
- property sliderStarted¶
Signal that gets fired when the slider is started
- Returns:
- property sliderFinished¶
Signal that gets fired when the slider is finished
- Returns:
- class FloatEdit(*args: Any, **kwargs: Any)¶
Bases:
StringEdit
- connections()¶
Connects the buttons and text changed emit
- Returns:
- Return type:
- setMinValue(val)¶
Set Min Value
- Parameters:
val –
- Returns:
- Return type:
- setMaxValue(val)¶
Set Max Value
- Parameters:
val –
- Returns:
- Return type:
- property sliderStarted¶
- property sliderFinished¶
- property sliderChanged¶
Tableview¶
- class TableView(*args: Any, **kwargs: Any)¶
Bases:
QTableView
Textedit¶
- heightForWidth(textEdit, width)¶
- lineCountToWidgetHeight(textEdit, num_lines)¶
Returns the number of pixels corresponding to the height of specified number of lines in the default font.
Thumbnailwidget¶
Togglewidgets¶
- class CheckableIcons(*args: Any, **kwargs: Any)¶
Bases:
ButtonIcons
RadioButton and CheckBox inherits from this this class to set up the icons that change on mouse over, press and release. Also the icons change when the button is checked or unchecked.
class ImageRadioButton(QtWidgets.QRadioButton, Checkable): def __init__(): self.initCheckables(uncheckedIconName="circle", checkedIconName="circleFilled", pressedIconName="circleFilled")
Must use initCheckables() when inherited in a subclass
- toggleClicked()¶
- initCheckables(uncheckedIconName, checkedIconName, pressedIconName)¶
- buttonPressed()¶
- buttonReleased()¶
- paintEvent(e)¶
- class RadioButton(*args: Any, **kwargs: Any)¶
Bases:
QRadioButton
,CheckableIcons
- class CheckBox(*args: Any, **kwargs: Any)¶
Bases:
QCheckBox
,CheckableIcons