Docking Pyside Widget in Maya 2016


#1

Hey guys,

I’m using the pymel method to dock my pyside widget in Maya.

Something like this in the init method of a class inherited by QMainWindow:

self.floatingLayout = pm.paneLayout( configuration = 'single', w=568, parent=mayaMainWindow())
pm.dockControl( 'NameOfWindowDockObject', aa=['right', 'left'], a='right', fl=False, con=self.floatingLayout, label='Title of Window', w=568 )
		pm.control( 'windowObjectName', e=True, parent=self.floatingLayout )

Which works fine in Maya 2013 and Maya 2016, in a sense that the Window is Docked, and appears on the right side in Maya when i run win.show()

In Maya 2013, the new tab generated on the dock is activated. Meaning it shows up in replacement of what was currently showing by default. The user doesn’t have to select the tab to see the tool trying to show.

However, In Maya 2016, the activation of the tool/window trying to show is not replaced anymore. The user must manually select the tab in the dock on the right for it to show up. Something changed in maya 2016, and now we have to somehow activate the window a different way. There must be a way when I run win.show()

Does anyone know a way to do this?
If i am not clear, i will elaborate more. please let me know. thanks
-Dan


#2

Maya mixin for dockables:
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/Maya-SDK/files/GUID-66ADA1FF-3E0F-469C-84C7-74CEB36D42EC-htm.html


#3

Appreciate the quick response, but I read this in the help docs and attempted to apply it to my code… unfortunately I got the same result. The window was docked properly, but not activated unless i manually selected the tab myself.


#4

Could you expand on “not activated”?
Not drawn? Or you have signals or calls not responding as you’d expect (e.g. hovering not registering until something in the window is clicked).


#5

Everything works as intended within the Tool, and the tab shows up on the right side as expected. However, the Tool is not ‘Activated’ meaning, it doesn’t replace itself as the current tab on the right side.

Here are my Examples:

In maya 2013-
on the right side panel… i have the channel box or attribute editor ‘Active’. meaning, I see it.
I run the win.show() in maya 2013 for my custom pyside widget… and the tab pops up on the right, and my pyside widget is now active. (I no longer See the attr editor or channel box) I see my widget, as expected.

In maya 2016-
on the right side panel… i have the channel box or attribute editor ‘Active’. meaning, I see it.
I run the win.show() in maya 2016 for my custom pyside widget… and the tab pops up on the right, and my pyside widget is not active.I still see the attr editor or channel box. I have to actually click the tab, to see it. or for my widget to actually be ‘Active’


#6

I see, that makes sense now. Sorry but I haven’t bumped into the issue (literally not needed somewhere else to change the docking space on the right, not that things work as you intend them for me).
Have you considered reporting it to AD?
Hopefully someone else has bumped into and solved the specific issue and will respond.


#7

My hope was that someone had the same issue. Maybe Autodesk added a flag to make it active or something like that… I was going to try here first, if not…then i will most definitely report it to Autodesk.

Thanks ThE_JacO.


#8

If you use the maya dock mixin class with your UI class, after you do a yourUIClass.show() you need to add the yourUIClass.raise_() method to raise the tab to the front.

-Sean


#9

Hey Sean, thank you for the insight -

_raise() didn’t work, as it isn’t a method that exists. So i went ahead and checked the modules existing methods by doing dir(MayaQWidgetDockableMixin)

This showed me that there was infact a method called raise, but its raise_()

For anyone else wanting to know how to do this, if you were previously using the old PyMel method using pm.dockControl and pm.control, remove this completely and just use the
MayaQWidgetDockableMixin method.

see link below:
http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__files_GUID_66ADA1FF_3E0F_469C_84C7_74CEB36D42EC_htm

After inheriting from this “MayaQWidgetDockableMixin”
do this:

ui = Window()
ui.show(dockable=True, area=‘right’, floating=False)
ui.raise_()

This works as expected now. Awesome.

thanks again Sean.


#10

But I wrote raise_() before.

Either way, glad it worked :slight_smile:
Cheers,
-Sean


#11

lol Cmon now, you edited that. :slight_smile:

thanks again.


#12

It would say if he did, any edit done after 2 minutes from the post confirmation shows an “edited by” footnote.
Anyway, thanks for raising the issue (no pun intended, I swear), it’s useful to know since I’m sure plenty people will bump into it. Thanks Nolan.


#13

Maybe I just read it wrong the first time then.
Regardless, I marked his post as useful as it did actually solve my issue.

Wonder why Autodesk changed this. Feel like it should raise_() by default.


#14

Haha, no worries!

I hear ya on the raise_() thing. If you dig a bit deeper into the code it boils down to a convenient class Autodesk wrote around the dockWidget class. The dockWidget gets docked into the bottom element of the parents index so visually the control is not visible by default. But yes, why would I build a control just to hide it. In my version of the mixin their was a typo making it so the control would not dock correctly. I posted it up on tech-artist.org but site is down for some reason.

You could just override the show() method in the mixin class and just add the raise_ method to it. I made a copy of the class a made a few tweaks to it myself, renamed it and moved it into my own lib/utils/ui classes.


#15

Awesome. I’ll probably do that too. thanks :slight_smile:

-Dan