Maya Python windowPref命令不会更改窗口宽度,但会更改窗口宽度

2024-09-21 01:13:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试设置非主Maya窗口(hypergraph等)的宽度。在

但命令实际上并没有移动它。它返回的结果是…这真的很奇怪。有人知道怎么回事吗?在

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

Tags: in命令truefor宽度windowswindowcmds
1条回答
网友
1楼 · 发布于 2024-09-21 01:13:45

根据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

相关问题 更多 >

    热门问题