ToolBarControlDemo 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 CommonStyle
from DevMachines.QtitanRibbon import RibbonPage, RibbonToolBarControl

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt, QPoint
    from PySide2.QtGui import QIcon, QFontDatabase
    from PySide2.QtWidgets import QApplication, QComboBox, QFontComboBox

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt, QPoint
    from PySide6.QtGui import QIcon, QFontDatabase
    from PySide6.QtWidgets import QApplication, QComboBox, QFontComboBox

from DemoRibbonWindow import DemoRibbonWindow

import ToolBarControlDemo_rc

class MainWindow(DemoRibbonWindow):
    def __init__(self):
        DemoRibbonWindow.__init__(self)
        self.setWindowTitle(self.tr("QtitanRibbon ToolBarControl Demo"))

        page = self.ribbonBar().addPage(self.tr("&Home"))
        self.createLargeButtons(page)
        self.createSmallButtons(page)
        self.createLargePlusSmallButtons(page)
        self.move(QPoint(200, 200))
        self.resize(1000, 300)

    def createLargeButtons(self, page):
        group = page.addGroup(self.tr("Large Buttons"))
        toolBar = RibbonToolBarControl(group)
        toolBar.addAction(QIcon(":/res/largeNewFile.png"), self.tr("New"), Qt.ToolButtonTextUnderIcon)
        toolBar.addAction(QIcon(":/res/largeOpenFile.png"), self.tr("Open"), Qt.ToolButtonTextUnderIcon)
        toolBar.addAction(QIcon(":/res/largePrint.png"), self.tr("Print"), Qt.ToolButtonTextUnderIcon)
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/largezoom.png"), self.tr("Zoom"), Qt.ToolButtonTextUnderIcon)
        toolBar.addAction(QIcon(":/res/largeWatermark.png"), self.tr("Watermark"), Qt.ToolButtonTextUnderIcon)
        group.addControl(toolBar)

    def createSmallButtons(self, page):
        group = page.addGroup(self.tr("Small Buttons"))
        toolBar = RibbonToolBarControl(group)

        fontComboBox = QFontComboBox()
        toolBar.addWidget(fontComboBox)

        sizeComboBox = QComboBox()
        sizeComboBox.setEditable(True)
        db = QFontDatabase()
        sizes = db.standardSizes()
        for size in sizes:
            sizeComboBox.addItem(str(size))
        toolBar.addWidget(sizeComboBox)
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/smallnew.png"), self.tr("New"))
        toolBar.addAction(QIcon(":/res/smallOpen.png"), self.tr("Open"))
        toolBar.addAction(QIcon(":/res/smallPrint.png"), self.tr("Print"))
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/smallRedo.png"), self.tr("Redo"))
        toolBar.addAction(QIcon(":/res/smallUndo.png"), self.tr("Undo"))
        toolBar.addAction(QIcon(":/res/smallreplace.png"), self.tr("Replace"))
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/smallfontshrink.png"), self.tr("Shrink"))
        toolBar.addAction(QIcon(":/res/smallfontgrow.png"), self.tr("Grow"))
        group.addControl(toolBar)

    def createLargePlusSmallButtons(self, page):
        group = page.addGroup(self.tr("Large+Small Buttons"))
        toolBar = RibbonToolBarControl(group)

#    toolBar.addAction(QIcon(":/res/largeNewFile.png"), self.tr("New"), Qt.ToolButtonTextUnderIcon)
#    toolBar.addAction(QIcon(":/res/largeOpenFile.png"), self.tr("Open"), Qt.ToolButtonTextUnderIcon)
#    toolBar.addAction(QIcon(":/res/largePrint.png"), self.tr("Print"), Qt.ToolButtonTextUnderIcon)
#    toolBar.addSeparator()

        toolBar.addAction(QIcon(":/res/largezoom.png"), self.tr("Zoom"), Qt.ToolButtonTextUnderIcon)
        toolBar.addAction(QIcon(":/res/largeWatermark.png"), self.tr("Watermark"), Qt.ToolButtonTextUnderIcon)
        toolBar.addSeparator()

        toolBar.addAction(QIcon(":/res/smallnew.png"), self.tr("New"))
        toolBar.addAction(QIcon(":/res/smallOpen.png"), self.tr("Open"))
        toolBar.addAction(QIcon(":/res/smallPrint.png"), self.tr("Print"))
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/smallRedo.png"), self.tr("Redo"))
        toolBar.addAction(QIcon(":/res/smallUndo.png"), self.tr("Undo"))
        toolBar.addAction(QIcon(":/res/smallreplace.png"), self.tr("Replace"))
        toolBar.addSeparator()
        toolBar.addAction(QIcon(":/res/smallfontshrink.png"), self.tr("Shrink"))
        toolBar.addAction(QIcon(":/res/smallfontgrow.png"), self.tr("Grow"))
        toolBar.addSeparator()
        group.addControl(toolBar)
        group.addSeparator()
        group.addAction(QIcon(":/res/largeNewFile.png"), self.tr("New"), Qt.ToolButtonTextUnderIcon)
        group.addAction(QIcon(":/res/largeOpenFile.png"), self.tr("Open"), Qt.ToolButtonTextUnderIcon)
        group.addAction(QIcon(":/res/largePrint.png"), self.tr("Print"), Qt.ToolButtonTextUnderIcon)

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