help with QtGui methods.

556 views
Skip to first unread message

jettam

unread,
Oct 11, 2017, 12:54:51 AM10/11/17
to Python Programming for Autodesk Maya
Can someone tell me why I am getting this error.
I am running maya2017.  It appears the QtGui.QDiaLog doesn't exist. Can someone suggest what I should be looking for here instead.

from PySide2 import QtGui, QtCore, QtUiTools
from shiboken2 import wrapInstance

import maya.cmds as mc
import maya.OpenMayaUI as omui

def getMayaWindow():
   
''' pointer to the maya main window '''
    ptr
= omui.MQtUtil.mainWindow()
   
if ptr:
       
return wrapInstance(Long(ptr), QtGui.QMainWindow)
       
def run():
   
''' builds our UI '''
   
global win
    win
= GeometryGenerator(parent=getMayaWindow())
    win
.show()
   
class GeometryGenerator(QtGui.QDiaLog):
   
   
def __init__(self,parent=None):
       
super(GeometryGenerator,self).__init__(parent)

# Error: 'module' object has no attribute 'QDiaLog'
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
# AttributeError: 'module' object has no attribute 'QDiaLog' # 

Joe Weidenbach

unread,
Oct 11, 2017, 1:18:03 AM10/11/17
to Python Programming for Autodesk Maya

So, the key to this is that in Maya 2017 you’re using PySide2, not PySide. This means a switch (under the hood) from Qt4 to Qt5. It’s not super-significant, but it means that things might not be where you would expect them to be as a seasoned Qt developer, and that a LOT of the old training material will be incorrect.

The biggest issue is that the widgets portion of Qt got pulled out of QtGui and into QtWidgets, but it’s not quite as simple as just switching the names, as Drawing, Icons, Pixmaps, etc are all still in the QtGui module. So, in your case, QtGui.QDialog no longer exists—that’s 100% correct. It is instead QtWidgets.QDialog().

So this should suffice:

from PySide2 import QtWidgets, QtCore, QtUiTools
from shiboken2 import wrapInstance

import maya.cmds as mc
import maya.OpenMayaUI as omui

def getMayaWindow():
    ''' pointer to the maya main window '''
    ptr = omui.MQtUtil.mainWindow()
    if ptr:
        return wrapInstance(Long(ptr), QtGui.QMainWindow)

def run():
    ''' builds our UI '''
    global win
    win = GeometryGenerator(parent=getMayaWindow())
    win.show()

class GeometryGenerator(QtWidgets.QDiaLog):

    def __init__(self,parent=None):
        super(GeometryGenerator,self).__init__(parent)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/32c94e48-1794-481d-afda-1e3f520b2e12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Anderson

unread,
Oct 11, 2017, 1:18:11 AM10/11/17
to Python Programming for Autodesk Maya
I think its been moved to QWidgets in QT v5

Joe Weidenbach

unread,
Oct 11, 2017, 1:21:37 AM10/11/17
to Python Programming for Autodesk Maya

Also you can get some good reference here


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Oct 11, 2017, 4:48:04 AM10/11/17
to python_in...@googlegroups.com

Yeah, it’s in QtWidgets but you’ve also misspelled QDialog


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da7o7%3D-V%2B9CBqrF_0dmQ5iLg0btt6hnuuxCZvHWW2T%2BkwA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages