short demonstration:
maya_window_name = mel.eval('$tmpVar = $gMainWindow;')
shelf_top_level = mel.eval('global string $gShelfTopLevel; $temp = $gShelfTopLevel;')
all_shelfs_tabs_names = cmds.tabLayout(shelf_top_level, query = True, childArray = True)
shelf_tab_name = cmds.tabLayout(shelf_top_level, query = True, selectTab = True)
current_shelf = '{}|{}'.format(shelf_top_level, shelf_tab_name)
buton_name = 'Reload All Textures in Viewport'
cmds.shelfButton(enableCommandRepeat = True,
annotation = buton_name,
label = buton_name,
imageOverlayLabel = 'Reload\nTexture',
command = 'cmds.ogs(reloadTextures = True)',
sourceType = 'python',
flexibleWidthType = 3,
flexibleWidthValue = 32,
enable = 1,
width = 35,
height = 34,
manage = 1,
visible = 1,
preventOverride = 0,
enableBackground = 0,
backgroundColor = (0.0, 0.0, 0.0),
highlightColor = (0.321569, 0.521569, 0.65098),
align = 'center',
labelOffset = 0,
rotation = 0,
flipX = 0,
flipY = 0,
useAlpha = 1,
font = 'plainLabelFont',
overlayLabelColor = (0.0, 1.0, 1.0),
overlayLabelBackColor = (0.0, 0.0, 0.0, 0.5),
image = 'commandButton.png',
image1 = 'commandButton.png',
style = 'textOnly',
marginWidth = 1,
marginHeight = 1,
commandRepeatable = 1,
flat = 1,
parent = current_shelf)
print (('\t Creating Button \"{}\" on shelf: \"{}\" - complete.\n'
).format(buton_name, shelf_tab_name))
separator = cmds.separator(parent = current_shelf,
enable = 1,
width = 12,
height = 35,
manage = 1,
visible = 1,
preventOverride = 0,
enableBackground = 0,
backgroundColor = (0, 0, 0),
highlightColor = (0.32, 0.52, 0.65),
style = 'shelf',
horizontal = 0)
print('\n\t Creating Separator on shelf: \"{}\" - complete.\n'.format(shelf_tab_name))
cmds.saveAllShelves(shelf_top_level)
tabLayout command (Python):