Using tabLayout, formlayout to set up ui

Hello!

Im attempting to set up a UI in maya to handle joint chain switching and space switching. There are two top tabs; one for set up and one for switching. The issue im having lies with the tabs. in the first tab I want I want each arm selection to be in a collapse-able tap that the user can click on to expand . I tried messing about with the maya examples and using an example from another question here but I’m not sure what I’m doing incorrectly. this is what I got

import maya.cmds as mc
import maya.cmds as cmds
import maya.OpenMaya as om
global jointName
global controllerName
global gtSL1
global gtSL2
import pymel.core as pm
 
from functools import partial

def frameCollapseChanged(mainLayout):
         mc.evalDeferred("mc.window('ToolUI', e=1, h=sum([eval('mc.' + mc.objectTypeUI(child) + '(\\'' + child + '\\', q=1, h=1)') for child in mc.columnLayout('" + mainLayout + "', q=1, ca=1)]))")
 
     #check to see if window exists
if mc.window("ToolUI", exists = True):
     mc.deleteUI("ToolUI")
     #create window
ToolWindow = mc.window("ToolUI", title = "Tool UI", w = 300, h = 300, mnb = True, mxb = False, sizeable = False)
    #create a main layout
mainLayout = mc.columnLayout (w =300)
form = cmds.formLayout()
tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5,w=300)
cmds.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)) )
 
child1 = cmds.columnLayout(columnAttach=('both', 5), columnWidth=200,adjustableColumn=True, columnAlign="center" )
 
     ### FIRST TAB ###
child1 = mc.frameLayout (width = 300, label = "Set Up", collapse = True, collapsable = True, marginWidth = 5, parent = mainLayout, ec=partial(frameCollapseChanged, str(mainLayout)), cc=partial(frameCollapseChanged, str(mainLayout)))
     #create a button
mc.button (label = "Button 1", w = 280, h = 50, command = 'print "hello",', parent = frameLayout1)
     #create a button
mc.button (label = "Button 2", w = 280, h = 50, command = 'print "hello",', parent = frameLayout1)
     #create a button
mc.button (label = "Button 3", w = 280, h = 50, command = 'print "hello",', parent = frameLayout1)
 
 
     ### SECOND TAB ###
child2 = mc.frameLayout (width = 300, label = "Tab 2", collapse = True, collapsable = True, marginWidth = 5, parent = mainLayout, ec=partial(frameCollapseChanged, str(mainLayout)), cc=partial(frameCollapseChanged, str(mainLayout)))
     #create a button
mc.button (label = "Button 4", w = 280, h = 50, command = 'print "hello",', parent = frameLayout2)
    #create a button
mc.button (label = "Button 5", w = 280, h = 50, command = 'print "hello",', parent = frameLayout2)
     #create a button
mc.button (label = "Button 6", w = 280, h = 50, command = 'print "hello",', parent = frameLayout2 )
 
     #show window
mc.showWindow(ToolWindow)
 
cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'One'), (child2, 'Two')) )



 
winHeight = 0
     # iterate through all children of the main layout
for child in mc.columnLayout(mainLayout, 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
     winHeight += eval('mc.' + mc.objectTypeUI(child) + '("' + child + '", q=1, h=1)')
     # set the window height with the gathered height values
mc.window('ToolUI', e=1, h=winHeight)

Also is there anything out there to show how exactly this works?

Hi, can you try editing your post? Your indentation all got lost. Depending on where you copied from, you might have to use ctrl-shift-V to paste without formatting, which might save your indentations.

think I got it in there correctly now. had to hit the pre formatted text to get it

It still looks rather messed up.

You want to enclose it in triple backticks: ```

whelp third times the charm i suppose, better now?

Your indentation is still messed up, there is no way to run that and get anything coherent from it.

This is really weird…Maybe typing it out rather than copypasting will finally get it