您手头有几个选项,具体取决于您希望它的外观...这些都是默认的 python / maya 函数,并且可以在以前的版本中使用,回到 Autodesk Maya 2012。
停靠您的窗口
您可以将窗口停靠到特定的一侧,这将有助于您在 Maya 中管理您的场景。最简单的方法是:
# Import your maya command package
import maya.cmds as cmds
try:
# Try to delete your window then the dock
cmds.deleteUI("yourWnd")
cmds.deleteUI("yourDock")
except:
pass
# Parent your window to this dock and then show the dock instead of the window
cmds.window("yourWnd")
cmds.columnLayout("col")
cmds.button("button1")
cmds.setParent("col")
cmds.dockControl("yourDock",
allowedArea = ["left","right"],
area = "left",
content = "yourWnd",
floating = False)
这会将您的 UI 放置在 Maya 窗口中易于访问的位置。
调整窗口大小
如果您决定创建一个窗口,您可以轻松地添加一个按钮或在您的窗口中调整窗口大小...
import maya.cmds as cmds
import ctypes
# having imported the ctypes package, you can get viable os system info
user32 = ctypes.windll.user32
# Getting the screen size of your main window
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
cmds.window("yourWnd")
cmds.columnLayout("col")
# A button that allows you to imitate maximizing your window on your mainscreen
cmds.button("maxPlease",
label = "Maximize",
command = """cmds.window("yourWnd",
edit=True,
topLeftCorner = [0,0],
widthHeight = [screensize[0],
screensize[1]])
""")
cmds.setParent("col")
cmds.showWindow("yourWnd")
这些只是基础知识,您可以混合搭配这两者来制定您自己的解决方案。我强烈推荐使用 ctypes,因为它肯定会帮助您调整大小以最大化您的窗口。