HTransparentDialogOnViewport

class source.Qt.custom_widget.HTransparentDialogOnViewport(*args: Any, **kwargs: Any)

Create a Custom Qwidget that will follow the maya Viewport while allowing transparency/semiTransparency

../_images/HTransparentDialogOnViewport.gif

Todo

  • Allow to minimize the window to different side (top left, top right, bottom left, bottom right)

Parameters
  • object_name (str) – Name of the window that’ll be created

  • parent (HTransparentDialogOnViewport) – Parent the window to an other HTransparentDialogOnViewport, optional

  • pos (list) – Position where the windows will appear base on the maya viewport, defaults [0,0]

  • size (list) – Default size of the created window , defaults [50,50]

  • visible (bool) – If the windows should be visible when created or not, defaults False

  • orientation (str) – Define the layout orientation onf the window, defaults horizontal

  • opacity (float) – Define the opacity of the window, defaults 0.5

Danger

  • parent need to be a HTransparentDialogOnViewport for it to work

  • orientation only accept ‘horizontal’ or ‘vertical’

  • opacity value should be contain between 0.0 and 1.0

Example:

import Qt.custom_widget as cstm_widget

TOOL_ICON = QtGui.QIcon(":/images/my_tool_icon.png")

class MyCustomUI(QtCore.QObject):
        def __init__(self):
            super(MyCustomUI, self).__init__()

            # ui creation
            self.main_ui = cstm_widget.HTransparentDialogOnViewport('anim sculpt',
                                                                pos=[10, 10],
                                                                size=[400, 30],
                                                                tool_icon=TOOL_ICON,
                                                                visible=True)
            self.my_button = QtWidgets.QPushButton('press me')

            # to add widget to the main ui use ``main_layout``
            self.main_ui.main_layout.addWidget(self.my_button)


            # to run function when user quit ui use ``ui_leaved``
            self.main_ui.ui_leaved.connect(my_leave_function)

UI = MyCustomUI()
UI.main_ui.show()

Functions

HTransparentDialogOnViewport.create_connections()

Create all connection of QWidget

HTransparentDialogOnViewport.create_context_menu()

Create the context menu

HTransparentDialogOnViewport.create_layout()

Create all layout of QWidget

HTransparentDialogOnViewport.create_widgets()

Create all Widget of QWidget

HTransparentDialogOnViewport.eventFilter(…)

Create eventfilter to install on maya UI to detect UI event

HTransparentDialogOnViewport.get_viewport_zone()

define the boundary of the viewport zones

HTransparentDialogOnViewport.get_window_pos_from_viewport()

Return widget position relative to the viewport

HTransparentDialogOnViewport.maximize()

Maximize widget

HTransparentDialogOnViewport.minimize()

Minimize widget or hide it if windows is child

HTransparentDialogOnViewport.mouseDoubleClickEvent(…)

What to do in case of mouse doubleclick event

HTransparentDialogOnViewport.mouseMoveEvent(…)

What to do in case of mouse move event

HTransparentDialogOnViewport.mousePressEvent(…)

What to do in case of mouse press event

HTransparentDialogOnViewport.mouseReleaseEvent(…)

What to do in case of mouse release event

HTransparentDialogOnViewport.move_widget_with_viewport(event)

Bind widget position to viewport

HTransparentDialogOnViewport.paintEvent(event)

Paint the semi transparent window

HTransparentDialogOnViewport.set_window_zone()

Assign a zone to the widget depending of it’s relative position to the viewport

HTransparentDialogOnViewport.ui_quit()

delete the tool when quiting it and emit signal