Embed Maya Native UI Objects in PySide2 (Maya 2017+)
This post has been moved to the author personal blogsite here:
http://blog.lidia-martinez.com/embed-maya-native-ui-objects-in-pyside2-maya-2017
News and articles from our studio
This post has been moved to the author personal blogsite here:
http://blog.lidia-martinez.com/embed-maya-native-ui-objects-in-pyside2-maya-2017
Any luck getting this approach to run in a class?
I should clarify…any luck putting the paneLayout and modelPanel in its own class and then using that inside of a pySide UI that is built as a class inheriting from QDialog?
I don’t understand! What do you mean by “in its own class”.
i guess the better question..is there a way to do this without using a PySide Layout?
Well. You are adding a widget (in this case, it’s a paneLayout, which in Maya’s UI is a widget, anyway) to another widget in Qt. So you need a layout, anyway.
Any chance to add QWidget to maya layout. I’m trying to add maya frame layout to Qt UI and QWidgets to that frame layout.
Hi! I don’t understand your question. You first say “add QWidget -> maya layout” and then you say ” add maya layout to Qt” again. You mean, adding a QWidget to a maya item?
Yes, I mean QWidget to maya item!
Thank you
That’s a good point. I never really tried it. That’s good for another article! In the meantime I suggest you visit StackOverflow or a similar forum where you can get an answer faster! I’m quite busy these days. Cheers
you can set objectName on Qt Widget and parent it to a maya layout. Try this minimal example,
import maya.cmds as mc
import maya.OpenMayaUI as omui
from PySide2.QtWidgets import QListWidget
qt_widget = QListWidget()
qt_widget.setObjectName(“QT_ListWidget”)
qt_widget.addItems(“Qt in maya is interesting”.split(” “))
win = mc.window()
col_lay = mc.columnLayout(adj=1)
mc.control(“QT_ListWidget”, e=1, p=col_lay)
mc.showWindow(win)
please replace the double quotes if you are copying the above code, or you might get a syntax error because the double quote is formatted when I posted the reply,
Thanks
That’s really nice, Vaishak. Thanks for the tip! I’ll try it as soon as possible.
Hey…Thanks buddy!!
Hey there! this might look silly, but i’m just starting at this coding thing! 🙂 how can i make this window to be the Graph Editor?
Hi ! It’s a pretty good question, of course. It’s not silly ^_^.
I had never done this, but opening the GraphEditor I activated “Show All Commands” in the script editor to see what’s going on in the backstage… (Be sure to turn Echo All Commands off again after this, or will make Maya terribly slow).
After that, I found out a couple of commands that are run when creating the GraphEditor.
outlinerEditor and animCurveEditor
So you should create both reading the documentation for those commands in the Maya Help.
You need to change this line:
modelPanelName = modelPanel("embeddedModelPanel#", cam='persp')
for this one:
modelPanelName = cmds.animCurveEditor("embeddedGraphEditor#", the rest of parameters here... if any)
But as you can see, this will just create the lower part of the editor. (The timeline). To get both parts you should create a Vertical Layout in Qt that contains the animCurveEditor this way and then repeat the whole process of adding another PaneLayout for the outlinerEditor.
Hey Lidia
Thanks for this helpful post! I’m using some of the code you have above in a tool I’m creating for a camera rig, but have run into an issue when giving the layout an arbitrary name.
Here’s my code: https://pastebin.com/vZcjxXiq
The implementation of your script begins after line 81.
The error I receive is: “line 88: setParent: Object ‘viewportLayout’ not found. # ”
I’m guessing this has to do with how I’m importing PySide2, but I need that flexibility since our studio is back and forth between Maya 2016 & Maya 2017+.
Any ideas on how to fix this?
About PySide and PySide2, use the very famous qt.py used but major vfx studios. https://pypi.python.org/pypi/Qt.py I suggest you visit the homepage.
I can see in your code you do this:
qtViewportLayout.setObjectName (“viewportLayout”)
I suggest you check there’s nothing else called like this. Try to run getObjectName afterwards. I suggest you store that in a variable and use it, instead of using directly the name. The other option is to create a unique name by adding a timestamp number after that string, so that it’s never the same.
cmds.setParent (“viewportLayout1283482439234”)
Thanks for the post. One thing that I have noticed is that the none of the commands on the modelEditorIconBar works. (i.e. if I click on the shaded icon, the viewport does nothing.) Is there a way to fix this issue?
Thanks
Any luck getting pyside2 to launch a ui in maya macos without crashing maya?
late to the party, thanks so much for this Lidia!
I’ve been searching far and wide to look for solutions for broken scripts that were written for pre-Maya 2017 at my studio, and this post was the only one that led me to a fix!
Thank you so much for taking time to write this post, Lidia.
You’re welcome. Thanks for your comment.
Thank you very much for your article, which solves a headache I have now. Anyway, this is a simple and efficient case demonstration.
The Raiders believe the ‘s finals scheduling has ‘made
it harder’ for them to beat the Storm in Melbourne next week, with Ricky Stuart complaining his team always draws ‘the short straw’.On Sunday, the
NRL confirmed the schedule for Week 1 of the finals, which
begin on Friday night at BlueBet Stadium when reigning
minor premiers Penrith host Parramatta as they look to move a step closer to a
second Grand Final triumphs in a row. The Raiders travel to Melbourne on Saturday night to take on the Storm at AAMI Park,
an arrangement which has left the club unimpressed. Canberra coach Ricky Stuart bemoaned his team’s luck when it came to finals scheduling RELATED ARTICLES
Share this article Share Canberra played on Sunday afternoon as they
strolled to a 52-10 annihilation of the Tigers at Leichhardt Oval to clinch eighth place. The Storm, however, will have
an extra two days of rest after losing to Parramatta on Thursday night in the
opening game of Round 25.’It’s made it harder for
us and it reminds me of 2020 because it’s not easy, but we’re used
to it,’ Raiders boss Don Furner told the .Two years
ago, the Storm and the Raiders faced each other in the preliminary final, with the
game played at Suncorp Stadium in Brisbane due to Covid-19 lockdowns in Victoria.
Melbourne thrashed Canberra 30-10 in the preliminary final in 2020, when the
two teams met at Suncorp Stadium in Brisbane due to Victoria’s Covid-19 lockdown
The Raiders have won in each of their last four trips
to AAMI Park, winning 20-16 in JulyWhile the Storm had been based on the Sunshine Coast, the Raiders were denied permission to travel to travel to Queensland 24 hours before kick-off.
Canberra were instead ordered to fly to Brisbane on the day of the game and
head directly to Suncorp Stadium.The less than ideal preparation saw the Raiders concede 22 unanswered
points in the first 24 minutes, a deficit they never recovered as they lost 30-10.’I’m just happy to be in the semis,’ Stuart said after
the win against the Tigers.
‘We are a club that’s very used to getting the short straw.’I thought we would play
on Sunday and then when we had 24 hours less [until the game] I thought to myself I’d make
a couple of changes.’Because we are playing on the Saturday
that gave me the idea to rest a few players.’
The Roosters and the Rabbitohs meet on Sunday night in their elimination final The Raiders had reportedly asked the NRL for
the finals to be the last one on the schedule, given they were the last
team to confirm their finals slot and travelled back to Canberra from
Sydney on Sunday night.The NRL has instead scheduled as
Saturday’s first game, to be followed by the qualifying final between Cronulla and the Cowboys at PointsBet Stadium.
A blockbuster Sydney rivalry ends Week 1 of the finals when the Sydney Roosters host the Rabbitohs at Allianz Stadium in a rematch of Round 25.Despite the short turnaround, the Raiders head
to Melbourne with plenty of optimism on the back of winning seven of their last eight games and four
straight win in the last four meetings with the storm at
AAMI Park. <div class="art-ins mol-factbox sport" data-version="2" id="mol-80deba00-2c66-11ed-8e49-511a934a1860" website unhappy with NRL over Week 1 finals scheduling