I have created a UI that can be launched inside Maya. My class for this window inherits from QDialog
. I want to have a button that will open a jpg
into a new window, and then it closes with another button. While this other window is open I would like to still be able to interact with the main window. Is it possible to do this? How would I go about launching this new window?
Asked
Active
Viewed 845 times
1
-
Read about modality in the documentation about QDialog. http://doc.qt.io/qt-4.8/qdialog.html – NoDataDumpNoContribution Nov 15 '17 at 10:47
1 Answers
1
You can use this code to get what you want. I tested it in Maya 2016.5 on macOS. Works fine!
import maya.cmds as cmds
def loadSecondWindow(*args):
window = cmds.window()
cmds.paneLayout()
cmds.image(image='/Users/swift/Desktop/scientist01.jpg')
cmds.showWindow(window)
def deleteSecondWindow(*args):
if (cmds.window('window2', exists=True)):
cmds.deleteUI('window2')
cmds.window(width=200)
cmds.columnLayout(adjustableColumn=True)
cmds.button(label='Window with Picture', command=loadSecondWindow)
cmds.button(label='Delete Window', command=deleteSecondWindow)
cmds.showWindow()

Andy Jazz
- 49,178
- 17
- 136
- 220