在maya中显示时如何设置宽度和高度/位置ui?

2024-09-27 19:12:53 发布

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

我为玛雅做了一个工具脚本。 它起作用了。我只想在它出现时设置默认位置/至少ui大小。你知道吗

有什么办法吗?你知道吗

我已经试过7个命令了。他们都没用。 用python2.7(Anaconda2)在vscode中测试的大多数代码

图像:

我尝试的是:

enter image description here

外观和我想要的:

enter image description here

# class and define prCLSRU tool
class pr_clsru_toolUI(pr_clsru_toolUI_form, pr_clsru_toolUI_base):
    def __init__(self, parent=None):
    # def __init__(self, parent=None, width=370, height=318): <-------- 1st try, nothing happen. When window show up, the size of window quite large
        super(pr_clsru_toolUI, self).__init__()
        self.setupUi(self)
        self.setDockNestingEnabled(True)
        #self.setMinimumSize(QtCore.QSize(370, 318)) <-------- 2nd try, nothing happen
if cmds.window( window_name, exists=True ):
    cmds.deleteUI( window_name )
else:
    cmds.window( title="prCLSRU tool for Maya v1.0.0", iconName="prCLSRU tool for Maya", widthHeight=(370, 318) ) #<-------- 3rd try, nothing happen. When window show up, the size of window quite large

if cmds.window( window_name, exists=True ):
    cmds.deleteUI( dock_control )
else:
    cmds.window( title="prCLSRU tool for Maya v1.0.0", iconName="prCLSRU tool for Maya", widthHeight=(370, 318) ) #<-------- 4th try, nothing happen. When window show up, the size of window quite large

window = pr_clsru_toolUI( MayaWindowPtr )
#7th try to resize
#cmds.window( window_name, edit=True, widthHeight=(370, 318) ) <-------- 7th try, nothing happen. When window show up, the size of window quite large
window.setObjectName( window_name )
# cmds.window( widthHeight=(370, 318) ) <-------- 5th try, nothing happen. When window show up, the size of window quite large
# cmds.window(resize(370, 318)) <-------- 6th try, nothing happen. When window show up, the size of window quite large
main = QDockWidget( dock_control, MayaWindowPtr )
main.setAllowedAreas( Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea )
main.setObjectName( dock_control )
main.setWidget( window )
main.setFloating( True )
main.show()

如你所见。我想要的是当我点击架子上的按钮时设置高度和宽度。(暗蓝绿色盒子内)

enter image description here


Tags: oftheselfsizemainshowwindowlarge
1条回答
网友
1楼 · 发布于 2024-09-27 19:12:53

正如杜鲁夫所说。 使它在中间突出并且有正确的大小。 使用时间: main.resize调整大小(“宽度值”、“高度值”)

把它放在: 主.set你知道吗等等等等.

谢谢你,@DhruvGovil

下面的样本https://twitter.com/prsfx/status/1168040492556115970/photo/1

相关问题 更多 >

    热门问题