I don't know how to put buttons aligns in my chosen order

I don't know how to put buttons aligns in my chosen order

aurelien.cova
Observer Observer
273 Views
2 Replies
Message 1 of 3

I don't know how to put buttons aligns in my chosen order

aurelien.cova
Observer
Observer

Hi,

 

I did an UI but I don't know how to put the button like the following example order (made with paint), it's the layout I expected :

 

Script.jpg

 

The script is that :

 

import maya.cmds as cmds
import maya.mel as mel

 

window = cmds.window( title="Tool", minimizeButton=False, maximizeButton=False, widthHeight=(200, 200) )

 

cmds.columnLayout( width=20 )

 

cmds.button( label='Tx' )
cmds.button( label='Ty' )
cmds.button( label='Tz', )

 

cmds.button( label='Rx' )
cmds.button( label='Ry', )
cmds.button( label='Rz', )

 

cmds.button( label='Clear' )
cmds.button( label='Reset' )

 

cmds.button( label='Translate' )
cmds.button( label='Rotate', )

 

cmds.setParent( '..' )

 

cmds.showWindow( window )

 

Thank you for the help

0 Likes
Accepted solutions (1)
274 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

You can assign variables to your Layouts and then use the parent (p) flag in further UI elements to give them a clear hierarchy. Your UI would looks something like this:

 

import maya.cmds as cmds
import maya.mel as mel

 

window = cmds.window( title="Tool", minimizeButton=False, maximizeButton=False, widthHeight=(200, 200) )

 

MainLayout = cmds.columnLayout( width=200 )
MainRow1 = cmds.rowLayout(nc = 3,p =  MainLayout)
MainRow2 = cmds.rowLayout(nc = 2,p =  MainLayout)
c1 = cmds.columnLayout( width=20, p = MainRow1 )
c2 = cmds.columnLayout( width=20, p = MainRow1 )
c3 = cmds.columnLayout( width=60, p = MainRow1 )


 

cmds.button( label='Tx', p= c1, bgc=[0.5,0,0] )
cmds.button( label='Ty', p= c1,bgc=[0,0.5,0]  )
cmds.button( label='Tz', p= c1,bgc=[0,0,0.5] )

 

cmds.button( label='Rx' , p= c2,bgc=[1,0,0])
cmds.button( label='Ry', p= c2, bgc= [0,1,0])
cmds.button( label='Rz', p= c2, bgc = [0,0,1] )

 

cmds.button( label='Translate', p= c3, h= 35,w= 60, bgc = [0,0,0.2] )
cmds.button( label='Rotate', p= c3,h= 35, w= 60, bgc = [0,0.2,0] )


cmds.button( label='Clear', p= MainRow2, w = 51 )
cmds.button( label='Reset', p= MainRow2, w= 51, bgc = [0.2,0.2,0.2] )

 

cmds.setParent( '..' )

 

cmds.showWindow( window )

 

 

I hope it helps!

Message 3 of 3

aurelien.cova
Observer
Observer

Hi!

 

Thank you for your reply, it's exactly that!

I didn't know the parent (p) flag to give them a clear hierarchy to my layout.

It's really useful, thank for this technique, it's helps a lot!

 

Thank you!