Q100098: Creating your own custom tab in the UI

Follow

SUMMARY

This article demonstrates how you can create your own custom type of tab and access it from Katana's main Tabs menu.

 

MORE INFORMATION

 
To create a custom tab you will need to:
 
1. Define a class derived from UI4.Tabs.BaseTab with its own layout of widgets.
2. Register that class as a plug-in of type 'KatanaPanel'
 
Here is a Python example illustrating the above:
 
from Katana import QtCore, QtGui, UI4

class MyCustomTab(UI4.Tabs.BaseTab):

    def __init__(self, parent):
        UI4.Tabs.BaseTab.__init__(self, parent)

        label = QtGui.QLabel('This is MyCustomTab')
        label.setObjectName('label')
        label.setStyleSheet('font-weight: bold; '
                            'font-size: 18pt; '
                            'font-style: italic;')

        hLayout = QtGui.QHBoxLayout()
        hLayout.setObjectName('hLayout')
        hLayout.addStretch()
        hLayout.addWidget(label)
        hLayout.addStretch()

        vLayout = QtGui.QVBoxLayout()
        vLayout.setObjectName('vLayout')
        vLayout.addLayout(hLayout)

        self.setLayout(vLayout)

PluginRegistry = [
    ('KatanaPanel', 2.0, 'MyCustomTab', MyCustomTab),
    ('KatanaPanel', 2.0, 'Custom/MyCustomTab', MyCustomTab),
]


REGISTRATION

In order to see the tab type in the UI, save the Python code into a .py file and place this inside of a Tabs subfolder of a directory whose path is added to the $KATANA_RESOURCES environment variable.

Tab types registered this way will show up in the Tabs menu of Katana's main menu bar, and in the Add Tab menu of each pane in a Katana layout.
 
NOTE:  You can group tab types inside of those menus by using path-like tab type names, such as 'Custom/MyCustomTab'

 


Keywords: Python, custom tab, Tabs menu

Was this article helpful?
2 out of 2 found this helpful