【问题标题】:Resizeable window command python-maya可调整大小的窗口命令 python-maya
【发布时间】:2017-03-22 15:17:36
【问题描述】:

自从我开始使用 Python 编写脚本以来,我就一直遇到这个问题。

尽管我在主“窗口”命令中添加了“宽度”和“高度”标志,但始终会根据最近的操作调整大小。 .明白我的意思吗?

难道它不应该总是给我在宽度和高度标志之后输入的相同大小吗?

有什么问题?

我不想使用相当大的标志,因为在使用 windows 时我总是需要调整它们。

这种奇怪行为背后的真正原因可能是什么?

我想打开我的窗口,无论我通过拖动窗口的一角调整它的大小多少次......

如果需要,这里是我的python代码...

import maya.cmds as cmds



def createGUI():

    #If the window already exists, it will delete it.
    if cmds.window('myWindow',exists=True): 
        cmds.deleteUI('myWindow')

    #Creation window command
    winControl=cmds.window('myWindow',title='BookShelf Generator',resizeToFitChildren=True, sizeable=False) #s=False does not allow the user to change the size of the window

    #Windows Layout
    #Top Part
    #Header image
    cmds.rowColumnLayout(w=400)
    cmds.image( image='/home/s4915717/Stefano_Feltre_Scripting/artefacts/Images/UIheader02.png' )
    cmds.setParent("..")

    cmds.columnLayout(adjustableColumn=True,rowSpacing=0)
    cmds.frameLayout( label='BookShelf Options',collapsable=False, mw=5, mh=5 )
    cmds.text(label='Modify the value on the interace to create different aspect of the BookShelf.', align='center', height = 20)
    cmds.separator(height=5)
    cmds.columnLayout()

    #Center Part
    ShelfSizeControl=cmds.intSliderGrp(label='Shelfs Size',minValue=5.0,maxValue=200.0, value=50.0,field=True)
    NumShelfsColumnControl = cmds.intSliderGrp(label='Num Shelfs Column', minValue=1, maxValue=10, value=3,field=True)
    NumShelfsRowControl = cmds.intSliderGrp(label='Num Shelfs Row', minValue=1, maxValue=10, value=3,field=True)
    GapShelfsColumnControl = cmds.intSliderGrp(label='Gap Column Shelfs', minValue=10, maxValue=50, value=10,field=True)
    GapShelfsRowControl = cmds.intSliderGrp(label='Gap Row Shelfs', minValue=1, maxValue=30, value=1,field=True)
    GapBooksControl = cmds.intSliderGrp(label='Gap Books', minValue=0, maxValue=1, value=0,field=True) #da controllare il valore massimo

    cmds.text(label='Books Direction', align='center', height = 20)
    DirectionControl = cmds.radioCollection()
    Direction0 = cmds.radioButton( label='Front',align='left')
    Direction1 = cmds.radioButton( label='Back',align='center')
    Direction2 = cmds.radioButton( label='Random',align='right')
    cmds.radioCollection( DirectionControl, edit=True, select=Direction0 )
    cmds.columnLayout(adjustableColumn=True,rowSpacing=0)
    cmds.separator(height=5)

    #Bottom Part
    #cmds.shelfButton(annotation='BookShelf Generator - Stefano Feltre', image = "commandButton.png", l='BookShelf', p='Custom', imageOverlayLabel='Spider', overlayLabelBackColor=(.6, .6, .6, .6), command=str("from SpiderGen import gui;reload(gui);gui.createUI()"))
    #vedere come caricare un bottone nel custom
    #Signature
    cmds.text(label='Stefano Feltre - 2017', w=400, h=30, font="smallPlainLabelFont") 



    #This command make appear the window
    cmds.showWindow(winControl)



createGUI()

我发现在命令“showwindow”之后添加了一个 MEL 代码。但我无法用 Python 翻译它……这里是:

if (`window -q -ex $winName`) deleteUI $winName;
        window -t "BookShelf Generator" $winName;
        showWindow $winName;
        window -e -wh 150 200 $winName;

【问题讨论】:

    标签: python user-interface command window maya


    【解决方案1】:

    在你展示你的窗口之后,只需使用相同的窗口命令并制作你想要的任何大小?

    cmds.showWindow(winControl)
    cmds.window('myWindow', e=True, width=500, height=800)
    

    【讨论】:

    • 我还不能投票...我有 11 个声誉,我需要 15 个...而且我不知道如何接受答案 ^^"
    • 我认为你应该在我的答案中有一个勾号按钮,如果不是这样的话;)..快乐编码
    • 哦,是的,找到了:D
    猜你喜欢
    • 2012-03-16
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多