Adding Custom Tab To Prism Settings#
This example plugin adds a custom tab to the Prism User Settings and a custom tab to the Prism Project Settings.
Custom widgets can be displayed in each of these tabs.
See the section for Single File Plugins on how to load this example.
# AddTabToSettings.py
name = "AddTabToSettings"
classname = "AddTabToSettings"
from qtpy.QtWidgets import *
class AddTabToSettings:
def __init__(self, core):
self.core = core
self.version = "v1.0.0"
# register projectSettings_loadUI callback. will be triggered when project settings open
self.core.registerCallback("projectSettings_loadUI", self.projectSettings_loadUI, plugin=self)
# register projectSettings_loadUI callback. will be triggered when user settings open
self.core.registerCallback("userSettings_loadUI", self.userSettings_loadUI, plugin=self)
def projectSettings_loadUI(self, origin):
# create a widget
origin.w_myPlugin = QWidget()
origin.lo_myPlugin = QVBoxLayout(origin.w_myPlugin)
# create a button
origin.b_myMessage = QPushButton("Press Me (Project)")
origin.b_myMessage.clicked.connect(lambda: self.core.popup("Hello"))
origin.lo_myPlugin.addWidget(origin.b_myMessage)
sp_stretch = QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)
origin.lo_myPlugin.addItem(sp_stretch)
# add tab to Project Settings
origin.addTab(origin.w_myPlugin, "My Plugin")
def userSettings_loadUI(self, origin):
# create a widget
origin.w_myPlugin = QWidget()
origin.lo_myPlugin = QVBoxLayout(origin.w_myPlugin)
# create a button
origin.b_myMessage = QPushButton("Press Me (User)")
origin.b_myMessage.clicked.connect(lambda: self.core.popup("Hello"))
origin.lo_myPlugin.addWidget(origin.b_myMessage)
sp_stretch = QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)
origin.lo_myPlugin.addItem(sp_stretch)
# add tab to User Settings
origin.addTab(origin.w_myPlugin, "My Plugin")