python - Maya Python windowPref 命令不会更改窗口宽度,但表示可以更改

标签 python user-interface window maya

我正在尝试设置非主 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/

相关文章:

python - 检查字典中的键是否定义

python - 模型实例上的 Django 引用管理器和相关管理器

Python 3 和 Pocket Sphinx

c++ - 将参数从 GUI 线程发送到工作线程

Java Swing 。如何检测其他组件/窗口移动到我的组件上方?

iphone - 不知道为什么 UIView 被推高了大约 10px

python - 运行游戏时出现空白窗口

python - 我需要一个 Python 中的 epub 到文本解决方案

java - 如何计算java应用程序绘制ui所需的时间?

Bash 脚本 - 确定脚本是在终端控制台还是在 gui 中启动