Thanks for the insight.
Yes, with statement is a nice option, but unfortunately i'm stuck with pymel
0.9.2 currently (for some reasons), and if i remembered correctly, with
statement is only available in pymel 1.0 +.


On Wed, Nov 24, 2010 at 10:13 PM, Ofer Koren <[email protected]> wrote:

> This is indeed a limitation with the current implementation of the
> horizontal/verticalLayout.
> The current workaround is to set the ratios all to 0 ([0,0,0], so that
> at least you get the left/right attachments for free), and then add a
> few attachNone/attachBottom/attachTop calls to re-attach the last two
> elements:
>
> (I recommend using the 'with' statement so you don't have to specify
> the 'parent' explicitly, but still maintain clarity in the code
> structure):
>
> win = window()
> with win:
>    topForm = verticalLayout(ratios=[0,0,0]) # use
> verticalLayout/horizontalLayout instead of formLayout (internally uses
> the same formLayout)
>    with topForm:
>        text1 = text(h=10, label='list')
>        TSL1 = textScrollList()
>        button1 = button(h=20)
>    # once outside of the 'with' block the form will redistribute
> automatically
>    topForm.attachForm(button1,'bottom',2)   # attach the last element
> to the bottom
>    topForm.attachNone(button1,'top')  # detach the top of the last
> element, so it respects its specified height
>    topForm.attachControl(TSL1, 'bottom', 2, button1)  # attach the
> previous element to the top of the last element
> # once outside of the 'with' block the window will display automatically
>
>
> - Ofer
> www.mrbroken.com
>
>
>
> On Tue, Nov 23, 2010 at 12:00 PM, r4inm4ker <[email protected]> wrote:
> > Hi all,
> > I had frequent use of the redistribute method in pymel's formLayout
> > and horizontalLayout. In some cases i want the ratio of the last child
> > to be fixed ( 0 ) . Consider an example below:
> >
> > ###################
> > from pymel.core import *
> > win = window()
> > topForm = formLayout(parent=win)
> > text1 = text(parent=topForm,h=10,label='list')
> > TSL1 = textScrollList(parent=topForm)
> > button1 = button(parent=topForm,h=20)
> > topForm.redistribute(0,2,0)
> > showWindow(win)
> > ###################
> >
> > the problem with the code above is that  button1 will not appear
> > because the last ratio is 0. My current workaround is to add invisible
> > dummy item with ratio 1 (i.e. text(parent=topForm,label='')) below the
> > last child  to force button1 to appear, but most of the time the final
> > redistribute effect is not what I wish to achieve( the last dummy item
> > will also be resized whenever the window is resized). Is there a
> > direct solution to this problem, or other "cheat" to make it work as
> > expected ?
> >
> > Hope I am clear, Thanks :)
> > Jefri
> >
> > --
> > http://groups.google.com/group/python_inside_maya
> >
>
> --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to