简体   繁体   English

Pyside:打开带有图片的新窗口

[英]Pyside: Opening a new window with picture

I have created a UI that can be launched inside Maya. 我创建了可以在Maya内部启动的UI。 My class for this window inherits from QDialog . 该窗口的类继承自QDialog I want to have a button that will open a jpg into a new window, and then it closes with another button. 我想要一个按钮,它将在新窗口中打开jpg ,然后用另一个按钮将其关闭。 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? 我将如何启动这个新窗口?

You can use this code to get what you want. 您可以使用此代码获得所需的内容。 I tested it in Maya 2016.5 on macOS. 我在macOS的Maya 2016.5中对其进行了测试。 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()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM