closing qDialog (if exists) in pySide


#1

Hi,

I created a UI in designer, converted it to python using pyside-uic and then following a tutorial I did this:

from PySide import QtCore, QtGui
import mirroratorUI as customUI
#import mirroratorCore as mirroratorCore
from shiboken import wrapInstance
import maya.OpenMayaUI as omui
reload(customUI)

def maya_main_window():
    main_window_ptr = omui.MQtUtil.mainWindow()
    return wrapInstance(long(main_window_ptr), QtGui.QWidget)

class ControlMainWindow(QtGui.QDialog):

    def __init__(self, parent=None):

        super(ControlMainWindow, self).__init__(parent)
        self.setWindowFlags(QtCore.Qt.Tool)
        self.ui =  customUI.Ui_MainWindow()
        self.ui.setupUi(self)

myWin = ControlMainWindow(parent=maya_main_window())
myWin.show()

The UI will be used into Maya, and it appears, but if I open it, for example, 3 times, I will have 3 dialgos. I remember there is a way to check if the dialog already exists, and if it does, deleting it. I found some info on google but I either didn’t understand how to use those info or they were not fit to my case…

Many thanks for your help,
Daniele