Reputation: 239
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 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 sue those info or they were not fit to my case...
Many thanks for your help, Daniele
Upvotes: 2
Views: 2296
Reputation: 356
Please try the below code.
global myWin
try:
myWin.close()
except:
pass
myWin = ControlMainWindow(parent=maya_main_window())
myWin.show()
The above code just finds out whether the windows exists and if it exists it will close and creates the window as usual.
Upvotes: 5