Maya Python Pyside2 GUI and Local Variable Passing Tutorial



I recently completed a Maya Python lesson for creating a Pyside2 GUI and passing local variables between definitions. These are two key things to know in order to create Python tools in Maya. I found the information on this a bit challenging to find, so I put together a simple lesson and template to share with all of you. Available in English and Urdu/Hindi.


Adnan Hussain


Line 75 has some code missing:
button.setStyleSheet(“background-color: rgb(128,128,128); color: rgb(0,0,0”) <-- At the end it should be )")

Why do you get the maya window as parent? Just wondering. There’s no need to do that.

Good work!


Thanks for the correction darkgaze :). Corrected in the github file. Luckily, it only caused the color to be incorrect on the button letters. Thanks for letting me know. As for the maya window parent part, I simply included it as it was a part of one of several sources I used to figure this out and cobble together a working template. Good to know it is not absolutely needed. I hope you found the code useful. Part of sharing that is so great, is to get feedback and learn from others, so thank you.



You’re welcome, :slight_smile:

Anything that can be a window itself (QDialog, QWindow and QWidget) if they don’t have a parent, the maya window will be its parent by default.

It will appear as another window together grouped with the maya window, but if you don’t want it to appear as a separated window but a toolbox inside Maya, you can use toolbox=true flag for native UI and I remember there was a similar way inside Qt, I don’t remember it right now.



Thanks again! This is useful info.