Stefano Feltre
Stefano Feltre

Reputation: 71

Resizeable window command python-maya

I have been having this issue since I began to write scripts with Python.

Even though I add "width" and "Height" flags to the main "window" command, the size is always adjusted according to recent manipulation. . Know what I mean?

Isn't it supposed to give me always the same size that I type after width and height flags?

What is the problem?

I do not want to use sizeable flag because I always need to adjust them while working with the windows.

What might possibly be the true reason behind this weird behaviour??

I want to open my window regardless of How many times I adjust its size by dragging the corner of the window ...

If necessary, here is my python code...

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()

I found a MEL code to add after the command "showwindow". But I'm not able to translate it in Python...Here it is:

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

Upvotes: 1

Views: 4747

Answers (1)

Achayan
Achayan

Reputation: 5895

After you show your window just use the same window command and make what ever size you want ?

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

Upvotes: 6

Related Questions