Package: maya-toolbar
Command launcher for MayaEver wanted more space on your shelf?maya-toolbaris a user interface designed to quickly access and execute user-defined commands.FeaturesResizable UIDockable UIPersistent UICustomizableTable of ContentsSystem RequirementsInstallationManualpipUsageAdd New TabsYAML ReferencesTabCategoryCommandMenuMenu itemcommandseparatormenuExecute functionEnvironment VariablesTOOLBAR_PATH_DISCOVERTOOLBAR_ACTIVE_TABTOOLBAR_AUTOLOADSystem RequirementsAutodesk Maya(2020+)In theory, itmayrun in older maya versions, but those are never being tested. If you try to use it on one of these versions and everything seems to works properly, please do not hesitate to let me know! :)YAMLThis will allow to write proper and readable configuration files that the UI will read to generate the user interface. The library is not included with the Maya installation, so we need to install it separately. Please see theinstallationsection below for details.InstallationThe installation can be done using two different methods.ManualLocated the mayascriptdirectory (or any other directory that will be available in thePYTHONPATH).Linux~/maya/scripts~/maya/{VERSION}/scriptsWindows~/Documents/maya/scripts~/Documents/maya/{VERSION}/scriptsMac OSLibrary/Preferences/Autodesk/maya/scriptsLibrary/Preferences/Autodesk/maya/{VERSION}/scriptsInstallpyyamlpackage.If your workstation is in a studio, there is a good chance that the library is already installed. If you are not sure, you can try running the following code:importyamlIf anImportErroris raised, the library needs to be installed, otherwise, you're good to go :)The easiest way to install it is to usepip. The--targetoption allows us to change the directory in which the package will be installed. In our case, we want to use thescriptsdirectory found above (or another directory that is a part of thePYTHONPATH).pipinstallpyyaml--target~/maya/scriptsDownload the filemaya_toolbar.pyand save it inside thescriptsdirectory.Seeusagebelow.pipmaya-toolbaris also uploaded onPyPIand can directly be installed usingpip. This means that all the dependencies will be automatically be installed without doing anything else!pipinstallmaya-toolbarLike in themanualsection, its possible to use the--targetoption to install the package in other directory, for example, the mayascriptsfolder.UsageTo open the toolbar, get a new python tab inside the script editor, and execute the following lines:importmaya_toolbarmaya_toolbar.show()The user interface will leave with the currentmaya workspace. This means that it will automatically reopen where it was left for the next Maya session!Enjoy! :)Add New TabsEach tab is represented by a singleYAMLfile which contains all the configuration to generate the UI.By default the tabs will be searched in the following directories (where~represent the$HOMEdirectory):Linux~/toolbar~/maya/toolbar~/maya/{VERSION}/prefs/toolbarWindows~/toolbar~/Documents/maya/toolbar~/Documents/maya/{VERSION}/prefs/toolbarMac OS~/toolbarLibrary/Preferences/Autodesk/maya/toolbarLibrary/Preferences/Autodesk/maya/{VERSION}/prefs/toolbarIn addition to these directories, every maya module that contains a directory calledtoolbarwill also be included.Arbitrary directories can also be added using theTOOLBAR_PATH_DISCOVERenvironment variable or directly from the python interpreter using thePATH_DISCOVERattribute:exportTOOLBAR_PATH_DISCOVER=$TOOLBAR_PATH_DISCOVER:path/to/directoryimportmaya_toolbarmaya_toolbar.PATH_DISCOVER.append("path/to/directory")maya_toolbar.show()YAML ReferencesAll the configure of the toolbar are done throughYAMLfiles. There will be no explanation of syntax here but its possible to learn it from theofficial documentation.See bellow all the different options available for each component of the toolbar.Tabname(str)- The name of the tab. If not specified, the name of the file will be used (without the extensions).load(bool)- Specify if the configuration should be loaded as a tab or not. Defaults toAUTOLOAD.categories(list)- The configuration of the categories.name:demoload:truecategories:[]Categoryname(str)- The name of the category.open(bool)- Should the category be extended or collapsed by default? Defaults tofalse.commands(list)- The configuration of the commands.name:Category Aopen:falsecommands:[]Commandname(str)- The name of the command (Displayed as a tooltip).icon(str)- The icon with which the command will be displayed.label(str)- A short text that will be displayed below the command.callback(str)- The function that should be executed (see the syntaxhere).menu(list)- The configuration of the menu.name:Command Aicon::mayaCommand.pnglabel:acallback:maya.cmds:NewScenemenu:[]Menuname(str)- The name of the menu.click(str)- The click that will show the menu (leftorright). Defaults toright.items(list)- The item to add as children.name:Menu Aclick:rightitems:[]Menu itemtype(str)- The type of the item to add. For each of them, different options are available:Additional options are available according to the specified type:commandname(str)- The name of the command.icon(str)- The icon with which the command will be displayed.callback(str)- The function that should be executed (see the syntaxhere).type:commandname:Menu command Aicon::mayaCommand.pngcallback:maya.cmds:NewSceneseparatorNo options are available.type:separatormenuname(str)- The name of the menu.icon(str)- The icon with which the menu will be displayed.items(list)- The item to add as children.type:menuname:Menu Aicon::mayaCommand.pngitems:[]Execute functionTo call a function, a special syntax similar to setuptools is used. The package name is separated from the function name using a:, where the package can be anything accessible from python (inside thePYTHONPATH)).So for example, if we have a module calledcommands.pyavailable inside ourPYTHONPATHand that contains the following code:defhello_world():print("Hello Word!")Inside theYAML configuration file, we can point to ourhello_worldfunction using:callback:commands:hello_worldEnvironment VariablesFunctionalities of the toolbar can be modified using environment variables.TOOLBAR_PATH_DISCOVERSimilar to what python does with thePYTHONPATH) variable, this allows the specified custom path to include in the search for the tab configuration file.echo$TOOLBAR_PATH_DISCOVERThe equivalent attribute in the python module isPATH_DISCOVER:importmaya_toolbarmaya_toolbar.PATH_DISCOVERTOOLBAR_ACTIVE_TABThe name of the tab that should have the focus when the user interface is opened or reloaded.echo$TOOLBAR_ACTIVE_TABThe equivalent attribute in the python module isACTIVE_TAB:importmaya_toolbarmaya_toolbar.ACTIVE_TABTOOLBAR_AUTOLOADSet the default loading behaviour for discovered configuration files.1means that all configuration files will be automatically loaded, unlessload: falseis explicitly specified.0is the exact opposite. Each configuration file will not be considered for loading unless theload: trueoption is specified.echo$TOOLBAR_AUTOLOADThe equivalent attribute in the python module isAUTOLOAD:importmaya_toolbarmaya_toolbar.AUTOLOAD