Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya 2017 docking window PySide2

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
compteg
6858 Views, 4 Replies

Maya 2017 docking window PySide2

Hi there,

 

I have a trouble when I want to parent a PySide Gui to the new way of docking window in Maya 2017. 

Why a PySide Gui can't parented to the "workspaceControl" command? However, it works fine with the MEL Gui commands.

Thanks guys!

4 REPLIES 4
Message 2 of 5
jdrese
in reply to: compteg

 

 

Hello

 

I have been trying to do the same but without success till now. I will let your know if I manage to find a way to manage this. You can use wrapInstance  to cast a workspaceControl Maya UI element into a Qt widget and then start adding your Qt widgets on top. The workspaceControl creates a QtWidget that has a QVBoxLayout on which you can add your widgets. I trying to override the layout by another one but it didn't worked out. I am still digging into this. Maya created custom QtWidget apparently called TWorkspacecontrol which seems to be their widget that is dockable. I have asked on several forums how to add to a QtWidget the same properties of their TWorkspacecontrol but I haven't recieve any answer on this.

 

You can try this...


from maya import cmds, OpenMayaUI
from shiboken2 import wrapInstance
from PySide2 import QtWidgets


control_element = cmds.workspaceControl('custom_workspace')
control_widget = OpenMayaUI.MQtUtil.findControl('custom_workspace')
control_wrap = wrapInstance(long(control_widget), QtWidgets.QWidget)

# widgets example to add
button_object = QtWidgets.QPushButton('Test Me')
control_wrap.layout().addWidget(button_object)

Message 3 of 5
jdrese
in reply to: jdrese

 

Hi

 

You can use this...

 

from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
from PySide2 import QtWidgets

 

class DialogWidget(MayaQWidgetDockableMixin, QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(DialogWidget, self).__init__(parent=parent)
        self.setObjectName('MY_CUSTOM_UI')
        self.setWindowTitle('TEST')
        layout = QtWidgets.QGridLayout()
        button = QtWidgets.QPushButton("HELP")
        layout.addWidget(button)
        self.setLayout(layout)

 

You can create an instance of this class and call your ClassInstance.show(dockable=True) and this will be dockable as the cmds.workspaceControl() command

Message 4 of 5
compteg
in reply to: jdrese

Hi,

 

It took me a long time to solve this .

Thank you so much! It works fine.

 

this is also helpful:

https://gist.github.com/liorbenhorin/217bfb7e54c6f75b9b1b2b3d73a1a43a

Message 5 of 5
jordanjs
in reply to: compteg

I don't understand any of this. I'm trying to dock my AnimSchool Picker next to the channel box, but not docked to the right of the entire Maya application. Could you please explain how I would do that, or provide an specific example I could copy and paste into my Script Editor that works? Thanks in advance...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report