Python window doesn't collapse properly


#1

Hi; I know this is a problem many people have but I have never been able to find a way to fix it.
To summarize, when running a Python script in Maya, collapsing a tab or frame layout does not collapse the window to fit the newly resized frame.

The fix that I tried was the following…

[quote=]cmds.frameLayout( label=‘frame1’, cll=True, cl=True, ec = partial (collapsedFrame, tab1 ), cc= partial (collapsedFrame, tab1 ), w=500, bgc= bgDkgray, parent=tab1)[/quote][quote=]def collapsedFrame( name, *args ): winHeight = 0 frameHeight = 0 # iterate through all children of the main layout for child in cmds.rowColumnLayout(name, q=1, ca=1): # for each child, get it’s type, then use that run an eval command to get that ui item’s height and add it to the height variable frameHeight = eval(‘cmds.’ + cmds.objectTypeUI(child) + ‘("’ + child + ‘", q=1, h=1)’) winHeight += frameHeight # set the window height with the gathered height values print "cycled: " + str(frameHeight) print str(winHeight) cmds.window(‘newWindow’, e=1, h=winHeight)[/quote]However, this is where I noticed an issue that throws a wrench in this solution. By looking at the print statements, I confirmed that the script, collapsedFrame, gets run before the frame actually gets closed, instead of after. The problem with this is that the math just doesn’t add up as expected. Instead of querying the heights of the frames after they’ve been collapsed, the program queries the heights of the frames before they get collapsed.
Does anyone have a solution to this?