krystosan 0 Junior Poster

I was experimenting with special methods, so I tried to create my own __new__ method , well just as expected it got called when the object was instantiated but the window that should show up didnt show even when i used super to retain the original __new__functionality.

from PySide.QtCore import *
from PySide.QtGui import *
from maya.OpenMayaUI import MQtUtil
import shiboken
def getMayaMainWindow(*args, **kwargs):
    '''@return: QtGui.QMainWindow instance of the top level maya window '''
    mainWindow = MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(mainWindow), QMainWindow) if mainWindow else None

class Test(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(Test, self).__init__(getMayaMainWindow())
        self.setWindowTitle('Test')
        self.show()
    def __str__(self):
        return "This is PySide window."
    def __new__(self):
        super(Test,self).__new__(self)

so how do I override new and object is instantiated properly and simillarly with del ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.