我正在尝试设置非主 Maya 窗口(超图等)的宽度。
但该命令实际上并没有移动它。它返回它确实......这真的很奇怪。有谁知道怎么回事吗?
openWindows = cmds.lsUI(windows=True)
for i, window in enumerate(openWindows):
if window != "MayaWindow":
widthQueryPre = cmds.windowPref(window, q=True, w=True)
cmds.windowPref(window, e=True, w=200) # Why doesn't this change the window's width?
widthQueryPost = cmds.windowPref(window, q=True, w=True)
print i, window, widthQueryPre, widthQueryPost
最佳答案
根据Maya 2014 documentation (我正在使用的版本):
Create or modify preferred window attributes. The size and position of a window is retained during and between application sessions. A default window preference is created when a window is closed. Window preferences must be named and, consequently, only affect the window with a matching name.
这意味着您使用windowPref
命令更改的值不是窗口的实际大小,而是默认大小。但是,当您关闭子窗口时也会调用此命令。并将覆盖您之前对 windowPref
的调用。
子窗口关闭后,您必须调用windowPref
。然后下次打开子窗口时,它的宽度将为 200px。
总结:此命令不会调整当前子窗口的大小,但设置其默认大小。
如果您想调整当前窗口的大小,请使用window
命令。
for win in cmds.lsUI(type="window"): #Lists all windows (including Pyside/PyQT ones)
if win != "MayaWindow" and cmds.window(win, query=True, exists=True): #cmds.window(win, query=True, exists=True) checks if the windows really exists (do it, this can be useful)
cmds.window( win, edit=True, widthHeight=(900, 777) ) #the actual command to resie the windows
关于python - Maya Python windowPref 命令不会更改窗口宽度,但表示可以更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33061364/