ToolBars 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, WindowTitleBar
from DevMachines.QtitanDocking import DockMainWindow, DockWidgetPanel

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt
    from PySide2.QtGui import QIcon, QKeySequence
    from PySide2.QtWidgets import (QAction, QActionGroup, QApplication, QMdiArea, QLineEdit, QLabel, QComboBox, QSpinBox, QTextEdit)

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt
    from PySide6.QtGui import QIcon, QKeySequence, QAction, QActionGroup
    from PySide6.QtWidgets import (QApplication, QMdiArea, QLineEdit, QLabel, QComboBox, QSpinBox, QTextEdit)

from DemoDockWindow import DemoDockWindow

import ToolBars_rc

class MainWindow(DemoDockWindow):
    def __init__(self, parent = None):
        DemoDockWindow.__init__(self, parent)
        self.mdiArea = QMdiArea()
        self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setCentralWidget(self.mdiArea)
        self.createActions()
        self.createMenus()
        self.createToolBars()
        self.createStatusBar()
        child = self.createMdiChild()
        child.showMaximized()
        child.setFocus()
        geom = self.screen().availableGeometry()
        self.resize(2 * geom.width() / 3, 2 * geom.height() / 3)
        self.readSettings()

    def createActions(self):
        self.fileNewAction = QAction(QIcon(":/res/new16x16.png"), self.tr("&New"), self)
        self.fileNewAction.setShortcuts(QKeySequence.New)
        self.fileNewAction.setStatusTip(self.tr("Create a document"))

        self.fileOpenAction = QAction(QIcon(":/res/open16x16.png"), self.tr("&Open"), self)
        self.fileOpenAction.setShortcuts(QKeySequence.Open)
        self.fileOpenAction.setStatusTip(self.tr("Open an existing document"))

        self.fileSaveAction = QAction(QIcon(":/res/save16x16.png"), self.tr("&Save..."), self)
        self.fileSaveAction.setShortcuts(QKeySequence.Save)
        self.fileSaveAction.setStatusTip(self.tr("Save the active document"))

        self.fileSaveAllAction = QAction(QIcon(":/res/save_all16x16.png"), self.tr("&Sa&ve All"), self)
        self.fileSaveAllAction.setShortcuts(QKeySequence.Save)
        self.fileSaveAllAction.setStatusTip(self.tr("Save All"))

        self.filePrintAction = QAction(QIcon(":/res/print16x16.png"), self.tr("Print"), self)
        self.filePrintAction.setStatusTip(self.tr("Print the active document"))

        self.editCutAction = QAction(QIcon(":/res/cut16x16.png"), self.tr("&Cut"), self)
        self.editCutAction.setShortcuts(QKeySequence.Cut)
        self.editCutAction.setStatusTip(self.tr("Cut the selection and put it on the Clipboard"))

        self.editCopyAction = QAction(QIcon(":/res/copy16x16.png"), self.tr("&Copy"), self)
        self.editCopyAction.setShortcuts(QKeySequence.Copy)
        self.editCopyAction.setStatusTip(self.tr("Copy the selection and put it on the Clipboard"))

        self.editUndoAction = QAction(QIcon(":/res/undo16x16.png"), self.tr("Undo"), self)
        self.editUndoAction.setStatusTip(self.tr("Undo the last action"))

        self.editRedoAction = QAction(QIcon(":/res/redo16x16.png"), self.tr("Redo"), self)
        self.editRedoAction.setStatusTip(self.tr("Redo the previously undone action"))

        self.editTogglebookmarkAction = QAction(QIcon(":/res/togglebookmark16x16.png"), self.tr("&Toggle Bookmark"), self)
        self.editTogglebookmarkAction.setStatusTip(self.tr("Inserts or removes a BookMark"))

        self.editNextbookmarkAction = QAction(QIcon(":/res/nextbookmark16x16.png"), self.tr("&Next Bookmark"), self)
        self.editNextbookmarkAction.setStatusTip(self.tr("Go to the next temporary bookmark"))

        self.editPreviousbookmarkAction = QAction(QIcon(":/res/previousbookmark16x16.png"), self.tr("&Previous Bookmark"), self)
        self.editPreviousbookmarkAction.setStatusTip(self.tr("Go to the previous temporary bookmark"))

        self.editClearallbookmarkAction = QAction(QIcon(":/res/clearallbookmark16x16.png"), self.tr("&Clear All Bookmark"), self)
        self.editClearallbookmarkAction.setStatusTip(self.tr("Clear all Bookmarks in the windows"))

        self.editFindAction = QAction(QIcon(":/res/find16x16.png"), self.tr("&Find"), self)
        self.editFindAction.setStatusTip(self.tr("Find the specified text"))

        self.editIncreaseIdentAction = QAction(QIcon(":/res/increaseident16x16.png"), self.tr("&Increase Ident"), self)
        self.editIncreaseIdentAction.setStatusTip(self.tr("Idents the selection text right one tab stop"))

        self.editDecreaseIdentAction = QAction(QIcon(":/res/decreaseident16x16.png"), self.tr("&Decrease Ident"), self)
        self.editDecreaseIdentAction.setStatusTip(self.tr("Idents the selection text left one tab stop"))

        self.buildActiveConfigurationAction = QAction(QIcon(":/res/activeconfiguration16x16.png"), self.tr("Select Active Configuration"), self)
        self.buildActiveConfigurationAction.setStatusTip(self.tr("Selects the active configuration"))

        self.buildDummyCompileAction = QAction(QIcon(":/res/dummycompile16x16.png"), self.tr("Compile"), self)
        self.buildDummyCompileAction.setStatusTip(self.tr("Compile the file"))

        self.buildDummyBuildAction = QAction(QIcon(":/res/dummybuild16x16.png"), self.tr("Build"), self)
        self.buildDummyBuildAction.setStatusTip(self.tr("Build the project"))

        self.buildDummyStopBuildAction = QAction(QIcon(":/res/dummystopbuild16x16.png"), self.tr("Stop Build"), self)
        self.buildDummyStopBuildAction.setStatusTip(self.tr("Stop the build"))

        self.buildDummyExecuteAction = QAction(QIcon(":/res/dummyexecute16x16.png"), self.tr("Execute Program"), self)
        self.buildDummyExecuteAction.setStatusTip(self.tr("Execute the program"))

        self.buildDummyGoAction = QAction(QIcon(":/res/dummygo16x16.png"), self.tr("Go"), self)
        self.buildDummyGoAction.setStatusTip(self.tr("Starts or continues the program"))

        self.editTogglebreakPointAction = QAction(QIcon(":/res/togglebreakpoint16x16.png"), self.tr("Insert/Remove Breakpoint"), self)
        self.editTogglebreakPointAction.setStatusTip(self.tr("Inserts or removes a breakpoint"))

        self.editRemoveAllBreakpointsAction = QAction(QIcon(":/res/removeallbreakpoints16x16.png"), self.tr("Remove All Breakpoints"), self)
        self.editRemoveAllBreakpointsAction.setStatusTip(self.tr("Removes all breakpoints"))

    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
        self.fileMenu.addAction(self.fileNewAction)
        self.fileMenu.addAction(self.fileSaveAction)
        self.fileMenu.addAction(self.filePrintAction)

        self.editMenu = self.menuBar().addMenu(self.tr("&Edit"))
        self.viewMenu = self.menuBar().addMenu(self.tr("&View"))
        self.createViewMenuStyle(self.viewMenu)
        self.menuBar().addSeparator()
        self.helpMenu = self.menuBar().addMenu(self.tr("&Help"))
        self.helpMenu.addAction(self.aboutAction)

    def createToolBars(self):
        self.fileToolBar = self.addToolBar(self.tr("Standard"), Qtitan.DockBarTop)
        self.fileToolBar.addAction(self.fileNewAction)
        self.fileToolBar.addAction(self.fileOpenAction)
        self.fileToolBar.addAction(self.fileSaveAction)
        self.fileToolBar.addAction(self.fileSaveAllAction)
        self.fileToolBar.addSeparator()
        self.fileToolBar.addAction(self.editCutAction)
        self.fileToolBar.addAction(self.editCopyAction)
        self.fileToolBar.addSeparator()
        self.fileToolBar.addAction(self.editUndoAction)
        self.fileToolBar.addAction(self.editRedoAction)
        self.fileToolBar.addSeparator()
        self.fileToolBar.addAction(self.editFindAction)
        self.fileToolBar.addSeparator()
        self.fileToolBar.addAction(self.filePrintAction)

        self.fileToolBar.addWidget(QLabel(self.tr("   Style:")))
        self.createComboBoxStyle()
        stylesAction = self.fileToolBar.addWidget(self.styleSwitcher)
        stylesAction.setToolTip(self.tr("Styles switcher"))

        self.fileToolBar.addSeparator()
        self.fileToolBar.addAction(self.aboutAction)

        self.editToolBar = self.addToolBar(self.tr("Edit"), Qtitan.DockBarTop)
        self.editToolBar.addAction(self.editTogglebookmarkAction)
        self.editToolBar.addAction(self.editNextbookmarkAction)
        self.editToolBar.addAction(self.editPreviousbookmarkAction)
        self.editToolBar.addAction(self.editClearallbookmarkAction)
        self.editToolBar.addSeparator()
        self.editToolBar.addAction(self.editFindAction)
        self.editToolBar.addSeparator()
        self.editToolBar.addAction(self.editIncreaseIdentAction)
        self.editToolBar.addAction(self.editDecreaseIdentAction)
        self.moveDockBar(self.fileToolBar, self.editToolBar)

        self.buildToolBar = self.addToolBar(self.tr("Build"), Qtitan.DockBarTop)
        self.buildToolBar.addAction(self.buildActiveConfigurationAction)
        self.buildToolBar.addSeparator()
        self.buildToolBar.addAction(self.buildDummyCompileAction)
        self.buildToolBar.addAction(self.buildDummyBuildAction)
        self.buildToolBar.addAction(self.buildDummyStopBuildAction)
        self.buildToolBar.addSeparator()
        self.buildToolBar.addAction(self.buildDummyExecuteAction)
        self.buildToolBar.addAction(self.buildDummyGoAction)
        self.buildToolBar.addAction(self.editTogglebreakPointAction)
        self.buildToolBar.addAction(self.editRemoveAllBreakpointsAction)

        self.editorsToolBar = self.addToolBar(self.tr("Editors 1"), Qtitan.DockBarTop)
        self.editorsToolBar.addWidget(QLabel("Editor:"))
        edit1 = QLineEdit("LineEdit 1")
        self.editorsToolBar.addWidget(edit1)
        edit2 = QLineEdit("LineEdit 2")
        self.editorsToolBar.addWidget(edit2)
        self.moveDockBar(self.buildToolBar, self.editorsToolBar)

        self.comboBoxToolBar = self.addToolBar(self.tr("ComboBox 1"), Qtitan.DockBarTop)
        self.comboBoxToolBar.addWidget(QLabel("ComboBox:"))
        comboBox1 = QComboBox()
        comboBox1.addItem("ComboBox 1")
        self.comboBoxToolBar.addWidget(comboBox1)
        comboBox2 = QComboBox()
        comboBox2.addItem("ComboBox 2")
        self.comboBoxToolBar.addWidget(comboBox2)
        self.moveDockBar(self.editToolBar, self.comboBoxToolBar)

        self.spinBoxToolBar = self.addToolBar(self.tr("SpinBox"), Qtitan.DockBarTop)
        self.spinBoxToolBar.addWidget(QLabel("SpinBox:"))
        spinBox1 = QSpinBox()
        spinBox1.setMinimumWidth(90)
        self.spinBoxToolBar.addWidget(spinBox1)
        spinBox2 = QSpinBox()
        spinBox2.setMinimumWidth(90)
        self.spinBoxToolBar.addWidget(spinBox2)
        self.moveDockBar(self.editorsToolBar, self.spinBoxToolBar)

        self.editorsToolBar2 = self.addToolBar(self.tr("Editors 2"), Qtitan.DockBarLeft)
        self.editorsToolBar2.addWidget(QLabel("Editor:"))
        edit11 = QLineEdit("LineEdit 1")
        edit11.setMinimumWidth(135)
        self.editorsToolBar2.addWidget(edit11)
        edit12 = QLineEdit("LineEdit 2")
        edit12.setMinimumWidth(135)
        self.editorsToolBar2.addWidget(edit12)

        self.comboBoxToolBar2 = self.addToolBar(self.tr("ComboBox 2"), Qtitan.DockBarLeft)
        self.comboBoxToolBar2.addWidget(QLabel("ComboBox:"))
        comboBox21 = QComboBox()
        comboBox21.setMinimumWidth(135)
        comboBox21.addItem("ComboBox 1")
        self.comboBoxToolBar2.addWidget(comboBox21)
        comboBox22 = QComboBox()
        comboBox22.setMinimumWidth(135)
        comboBox22.addItem("ComboBox 2")
        self.comboBoxToolBar2.addWidget(comboBox22)
        self.moveDockBar(self.comboBoxToolBar2, self.editorsToolBar2)

    def createStatusBar(self):
        self.statusBar().showMessage(self.tr("Ready"))

    def createMdiChild(self):
        child = QTextEdit()
        self.mdiArea.addSubWindow(child)
        return child

    def closeEvent(self, event):
        event.accept()
        self.writeSettings()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setApplicationName("PyQtitanDocking - Dock ToolBars")
    app.setOrganizationName("Developer Machines")
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())