Re: [Maya-Python] Maya 2018 PYQT4 - Designer UI issue

303 views
Skip to first unread message
Message has been deleted

Justin Israel

unread,
Dec 24, 2017, 6:24:02 AM12/24/17
to python_in...@googlegroups.com


On Sun, Dec 24, 2017, 11:02 PM Nitin Singh <nitinc...@gmail.com> wrote:


Hi Guys,

I am having this issue in maya 2018.

I made a UI in pyqt4 designer. I got it all working but for some reason Maya launches new version of UI when I run the script. It doesn't close the old already opened UI.
The title of window is different and scaling doesn't work. I have tried to solve it for few days but it doesn't work at all, any help will great.
I have attached the print screen of Maya and designer along with the .UI file I am laoding in Maya 2018.

########################################################################################################################################################################
########################################################################################################################################################################

from maya import cmds
from maya import mel
from maya import OpenMayaUI as omui
import os.path
import os, glob, time
import sys
import getpass
import maya.mel as mel


try:
  from PySide2.QtCore import *
  from PySide2.QtGui import *
  from PySide2.QtWidgets import *
  from PySide2.QtUiTools import *
  from shiboken2 import wrapInstance
except ImportError:
  from PySide.QtCore import *
  from PySide.QtGui import *
  from PySide.QtUiTools import *
  from shiboken import wrapInstance




mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

class CreateNodeUI(QWidget):
    def __init__(self, *args, **kwargs):
        super(CreateNodeUI,self).__init__(*args, **kwargs)
        self.setParent(mayaMainWindow)

        self.setWindowFlags( Qt.Window )       
        self.initUI()


    def initUI(self):
        loader = QUiLoader()
        file = QFile("C:/Users/nitin.singh/Desktop/polyReduce_001.ui")
        file.open(QFile.ReadOnly)
        self.ui = loader.load(file, parentWidget=self)
        file.close()


       
def main():
    ui = CreateNodeUI()
    ui.show()
    return ui
if __name__ == '__main__':
    main()

There is no logic in your code that would try and close a previously open widget when launching a new instance. Common patterns in the Maya commands api include looking for a window with the same object name and deleting it. The same could be done in pure Qt if you wanted to check for top level widgets with the same object name. But you aren't doing either of those things 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bf1f0625-4a7b-4ba8-b9b1-73abf4b4477e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Deke Kincaid

unread,
Dec 25, 2017, 1:37:01 PM12/25/17
to python_in...@googlegroups.com
You said you are using pyqt4 designer which I’m guessing you mean qt4 designer.  Since Maya is built using qt5, maybe try updating to qt5 designer?

########################################################################################################################################################################
########################################################################################################################################################################          
Reply all
Reply to author
Forward
0 new messages