ContextualTabs Example

import sys, os
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../shared")

from DevMachines import __pyside2__, __pyside6__
from DevMachines import QtitanBase
from DevMachines.QtitanBase import Qtitan, CommonStyle
from DevMachines.QtitanRibbon import RibbonWorkspace, RibbonSliderPane

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt
    from PySide2.QtGui import QIcon
    from PySide2.QtWidgets import QApplication

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt
    from PySide6.QtGui import QIcon
    from PySide6.QtWidgets import QApplication

from DemoRibbonWindow import DemoRibbonWindow

import ContextualTabs_rc

class MainWindow(DemoRibbonWindow):
    def __init__(self):
        DemoRibbonWindow.__init__(self)
        self.setWindowTitle(self.tr("QtitanRibbon Contextual Tabs"))
        workspace = RibbonWorkspace()
        self.setCentralWidget(workspace)
        self.createRibbon()
        self.createStatusBar()

        self.move(QtCore.QPoint(200, 200))
        geom = self.screen().availableGeometry()
        self.resize(2 * geom.width() / 3, 2 * geom.height() / 3)

    def createRibbon(self):
        page = self.ribbonBar().addPage(self.tr("Page"))
        group = page.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button"), Qt.ToolButtonTextUnderIcon)

        strContextTitle = self.tr("Contextual Group")
        strContextGroupName = "id_contextual_group"
        contextPage1 = self.ribbonBar().addPage(self.tr("Page 1"))
        group = contextPage1.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button 1"), Qt.ToolButtonTextUnderIcon)

        contextPage1.setContextColor(Qtitan.ContextColorRed)
        contextPage1.setContextTitle(strContextTitle)
        contextPage1.setContextGroupName(strContextGroupName)

        contextPage2 = self.ribbonBar().addPage(self.tr("Page 2"))
        group = contextPage2.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button 2"), Qt.ToolButtonTextUnderIcon)
        contextPage2.setContextColor(Qtitan.ContextColorRed)
        contextPage2.setContextTitle(strContextTitle)
        contextPage2.setContextGroupName(strContextGroupName)

        contextPage3 = self.ribbonBar().addPage(self.tr("Page 3"))
        group = contextPage3.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button 3"), Qt.ToolButtonTextUnderIcon)
        contextPage3.setContextColor(Qtitan.ContextColorRed)
        contextPage3.setContextTitle(strContextTitle)
        contextPage3.setContextGroupName(strContextGroupName)

        page = self.ribbonBar().addPage(self.tr("Page"))
        group = page.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button"), Qt.ToolButtonTextUnderIcon)

        context = self.ribbonBar().addPage(self.tr("Page"))
        group = context.addGroup(self.tr("Group"))
        group.addAction(QIcon(":/res/qtitanlogo32x32.png"), self.tr("Button"), Qt.ToolButtonTextUnderIcon)

        context.setContextColor(Qtitan.ContextColorBlue)
        context.setContextTitle(self.tr("Contextual"))

        self.ribbonBar().setFrameThemeEnabled()

    def createStatusBar(self):
        sliderPane = RibbonSliderPane()
        sliderPane.setScrollButtons(True)
        sliderPane.setRange(0, 100)
        sliderPane.setMaximumWidth(130)
        sliderPane.setSingleStep(10)
        sliderPane.setSliderPosition(50)
        self.statusBar().addPermanentWidget(sliderPane)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())