在maya中显示时如何设置宽度和高度/位置ui?
Posted
技术标签:
【中文标题】在maya中显示时如何设置宽度和高度/位置ui?【英文标题】:How to set width and height / position ui when show up in maya? 【发布时间】:2019-08-31 15:58:16 【问题描述】:我为 Maya 制作了一个工具脚本。 有用。我只想在它出现时设置默认位置/至少 ui 大小。
有没有办法做到这一点?
我已经尝试了大约 7 个命令。他们都不起作用。 大部分代码在 vscode 中用 python 2.7 (Anaconda2) 测试过
图片:
我尝试了什么:
它的外观和我想要的:
# 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()
如您所见。当我单击架子上的按钮时,我想要的是设置高度和宽度。 (在深青色盒子内)
【问题讨论】:
【参考方案1】:正如 Dhruv 建议的那样。 使其在中间弹出并具有正确的尺寸。 用过的: main.resize("widthValue", "heightValue")
把它放在前面: main.setetc.etc.
谢谢你,@DhruvGovil
下面的示例 https://twitter.com/prsfx/status/1168040492556115970/photo/1
【讨论】:
你也可以使用 setGeometry。以上是关于在maya中显示时如何设置宽度和高度/位置ui?的主要内容,如果未能解决你的问题,请参考以下文章