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 are some Python examples illustrating the above:
Katana 8.0
from Katana import UI4
from PySide6 import QtWidgets
class MyCustomTab(UI4.Tabs.BaseTab):
def __init__(self, parent):
UI4.Tabs.BaseTab.__init__(self, parent)
label = QtWidgets.QLabel('This is MyCustomTab')
label.setObjectName('label')
label.setStyleSheet('font-weight: bold; '
'font-size: 18pt; '
'font-style: italic;')
hLayout = QtWidgets.QHBoxLayout()
hLayout.setObjectName('hLayout')
hLayout.addStretch()
hLayout.addWidget(label)
hLayout.addStretch()
vLayout = QtWidgets.QVBoxLayout()
vLayout.setObjectName('vLayout')
vLayout.addLayout(hLayout)
self.setLayout(vLayout)
PluginRegistry = [
('KatanaPanel', 2.0, 'MyCustomTab', MyCustomTab),
('KatanaPanel', 2.0, 'Custom/MyCustomTab', MyCustomTab),
]Katana 7.5 and older
from Katana import UI4
from PyQt5 import QtWidgets
class MyCustomTab(UI4.Tabs.BaseTab):
def __init__(self, parent):
UI4.Tabs.BaseTab.__init__(self, parent)
label = QtWidgets.QLabel('This is MyCustomTab')
label.setObjectName('label')
label.setStyleSheet('font-weight: bold; '
'font-size: 18pt; '
'font-style: italic;')
hLayout = QtWidgets.QHBoxLayout()
hLayout.setObjectName('hLayout')
hLayout.addStretch()
hLayout.addWidget(label)
hLayout.addStretch()
vLayout = QtWidgets.QVBoxLayout()
vLayout.setObjectName('vLayout')
vLayout.addLayout(hLayout)
self.setLayout(vLayout)
PluginRegistry = [
('KatanaPanel', 2.0, 'MyCustomTab', MyCustomTab),
('KatanaPanel', 2.0, 'Custom/MyCustomTab', MyCustomTab),
]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.
You can group tab types inside of those menus by using path-like tab type names, such as Custom/MyCustomTab.
Every custom Tab folder is grouped together into a unique section. These sections can be assigned titles, which can be customized by placing a file named separatorTitle.txt in a Tabs folder within a KATANA_RESOURCES directory. For example, if you wanted "API Example Tabs" as a separator title you would simply put "API Example Tabs" in the separatorTitle.txt and the result would be as follows:
To have more than one custom Tab section you must have multiple unique directories assigned to KATANA_RESOURCES each with their own Tab folder. This is required because Katana only looks for the Tab folder, while only accepting one separatorTitle.txt per Tab folder, and cannot identify sub folders. For more information on adding new paths to KATANA_RESOURCES, please see the following article in the Katana Resources Install Guide.
FURTHER READING
If you are encountering any issues with this, then please open a Support ticket and let us know about the problem and which troubleshooting steps you have taken so far.
For more information on how to open a Support ticket, please refer to Q100064: How to raise a support ticket.
We're sorry to hear that
Please tell us why