CustomTitleBarDemo Example

import sys

from DevMachines import __pyside2__, __pyside6__
from DevMachines.QtitanBase import WindowTitleBar
from DevMachines.QtitanStyle import AdobePhotoshopStyle, Office2016Style

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

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

import CustomTitleBarDemo_rc
from ui_titlebarwidget import Ui_TitleBar as ui

class TitleBarWidget(QWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)

        self.setAutoFillBackground(False)
        self.setAttribute(Qt.WA_NoSystemBackground)
        self.setFont(QApplication.font("QDockWidgetTitle"))
        self.ui = ui()
        self.ui.setupUi(self)

        self.ui.labelCaption.setText(qApp.organizationName())
        self.ui.labelCaption.setAlignment(Qt.AlignCenter)
        height = self.ui.comboBox.sizeHint().height()
        self.ui.searchButton.setMinimumHeight(height)
        self.ui.searchButton.setIcon(QIcon(":/res/lens.png"))
        self.ui.refreshButton.setMinimumHeight(height)
        self.ui.refreshButton.setIcon(QIcon(":/res/refresh.png"))
        self.ui.stopButton.setMinimumHeight(height)
        self.ui.stopButton.setIcon(QIcon(":/res/stop.png"))
        self.ui.goto_forward.setMinimumHeight(height)
        self.ui.goto_forward.setIcon(QIcon(":/res/forward.png"))
        self.ui.goto_back.setMinimumHeight(height)
        self.ui.goto_back.setMinimumWidth(height)
        self.ui.goto_back.setIcon(QIcon(":/res/back.png"))

class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.titleBarWidget = TitleBarWidget(self)
        self.setFrameThemeEnabled(True)
        self.createProperties()
        geom = self.screen().availableGeometry()
        self.move(QtCore.QPoint(200, 200))
        self.resize(2 * geom.width() / 4, 2 * geom.height() / 4)

    def createProperties(self):
        ...

    def setFrameThemeEnabled(self, enable):
        if enable:
            titleBar = WindowTitleBar.get(self)
            titleBar.setStyledFrame(False)
            #titleBar.setSysMenuButtonVisible(False)
            titleBar.setTitleHeight(self.titleBarWidget.sizeHint().height())
            self.titleBarWidget.setParent(None)
            titleBar.setWidget(self.titleBarWidget, WindowTitleBar.AlignLeft)
            titleBar.show()
        else:
            titleBar = WindowTitleBar.find(self)
            if titleBar:
                titleBar.setWidget(None)
                titleBar.removeAndDelete()
                self.titleBarWidget.setParent(self)
                self.titleBarWidget.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setApplicationName("QtitanRibbon CustomTitleBar Demo")
    app.setOrganizationName("Developer Machines")
    #style = Office2016Style()
    #style.setTheme(Office2016Style.Black)
    #qApp.setStyle(style)
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())