ControlsDemo 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,
    RibbonControlSizeDefinition, RibbonCheckBoxControl, RibbonRadioButtonControl,
    RibbonToolBarControl, RibbonLineEditControl, RibbonComboBoxControl, RibbonSpinBoxControl,
    RibbonTimeEditControl, RibbonDateEditControl, RibbonDateTimeEditControl,
    RibbonFontComboBoxControl, RibbonLabelControl, RibbonSliderPaneControl,
    RibbonSliderControl)

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt, QTimer, QPoint
    from PySide2.QtGui import QIcon, QPixmap, QKeySequence
    from PySide2.QtWidgets import (QAction, QWidgetAction, QApplication, QButtonGroup,
        QFontComboBox, QProgressBar, QSlider, QMenu, QScrollBar, QMessageBox)

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt, QTimer, QPoint
    from PySide6.QtGui import QAction, QIcon, QPixmap, QKeySequence
    from PySide6.QtWidgets import (QWidgetAction, QApplication, QButtonGroup,
        QFontComboBox, QProgressBar, QSlider, QMenu, QScrollBar, QMessageBox)

from DemoRibbonWindow import DemoRibbonWindow

import ControlsDemo_rc

class MainWindow(DemoRibbonWindow):
    Prop_ContextColor = "ContextColor"
    def __init__(self):
        DemoRibbonWindow.__init__(self)

        self.valueProgress = 0
        self.setWindowTitle(self.tr("PyQtitanRibbon Controls"))
        self.setCentralWidget(RibbonWorkspace())

        self.createMenuFile()
        self.createQuickAccessBar()
        self.createRibbon()
        self.createStatusBar()

        self.timerProgressBar = QTimer()
        self.timerProgressBar.setInterval(200)
        self.connect(self.timerProgressBar, QtCore.SIGNAL("timeout()"), self.animateProgressBar)

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

    def createMenuFile(self):
        iconLogo = QIcon()
        iconLogo.addPixmap(QPixmap(":/res/qtitan.png"))
        iconLogo.addPixmap(QPixmap(":/res/qtitanlogo32x32.png"))
        actionFile = self.ribbonBar().addSystemButton(iconLogo, self.tr("&File"))
        actionFile.setToolTip(self.tr("Click here to see everything<br />you can do with your<br />document"))
        self.ribbonBar().systemButton().setToolButtonStyle(Qt.ToolButtonTextOnly)

        systemPopupMenu = self.ribbonBar().systemButton().systemMenu()
        if systemPopupMenu:
            newFile = systemPopupMenu.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_New), self.tr("&New"))
            newFile.setShortcut(self.tr("Ctrl+N"))
            newFile.setStatusTip(self.tr("Create a new document"))
            newFile.setToolTip(self.tr("New"))
            newFile.setEnabled(False)

            openFile = systemPopupMenu.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Open, True), self.tr("&Open..."))
            openFile.setShortcut(self.tr("Ctrl+O"))
            openFile.setToolTip(self.tr("Open"))
            openFile.setStatusTip(self.tr("Open an existing document"))
            self.connect(openFile, QtCore.SIGNAL("triggered()"), self.open)

            saveFile = systemPopupMenu.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Save, True), self.tr("&Save"))
            saveFile.setShortcut(self.tr("Ctrl+S"))
            saveFile.setToolTip(self.tr("Save"))
            saveFile.setStatusTip(self.tr("Save the active document"))
            self.connect(saveFile, QtCore.SIGNAL("triggered()"), self.save)

            saveAsFile = systemPopupMenu.addAction(self.tr("Save &As..."))
            saveAsFile.setToolTip(self.tr("Save As"))
            saveAsFile.setStatusTip(self.tr("Save the active document with a new name"))
            self.connect(saveAsFile, QtCore.SIGNAL("triggered()"), self.save)

            systemPopupMenu.addSeparator()

            printFile = systemPopupMenu.addAction(QIcon(":/res/print.png"), self.tr("&Print"))
            printFile.setShortcut(self.tr("Ctrl+P"))
            printFile.setToolTip(self.tr("Print"))
            printFile.setStatusTip(self.tr("Print the active document"))
            self.connect(printFile, QtCore.SIGNAL("triggered()"), self.print)

            printPreviewFile = systemPopupMenu.addAction(QIcon(":/res/printPreview.png"), self.tr("Print Pre&view"))
            printPreviewFile.setToolTip(self.tr("Print Preview"))
            printPreviewFile.setStatusTip(self.tr("Display full pages"))

            printSetupFile = systemPopupMenu.addAction(self.tr("P&rint Setup..."))
            printSetupFile.setToolTip(self.tr("Print Setup"))
            printSetupFile.setStatusTip(self.tr("Change the printer and printing options"))
            self.connect(printSetupFile, QtCore.SIGNAL("triggered()"), self.printSetup)

            systemPopupMenu.addSeparator()

            actClose = systemPopupMenu.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Close), self.tr("&Close"))
            actClose.setShortcut(self.tr("Ctrl+C"))
            actClose.setStatusTip(self.tr("Exit"))
            self.connect(actClose, QtCore.SIGNAL("triggered()"), self.close)

            systemPopupMenu.addPopupBarAction(actClose, Qt.ToolButtonTextBesideIcon)

            option = QAction(QPixmap(":/res/smalloption.png"), self.tr("Opt&ion"), self)
            systemPopupMenu.addPopupBarAction(option, Qt.ToolButtonTextBesideIcon)
            option.setEnabled(False)

            pageRecentFile = systemPopupMenu.addPageRecentFile(self.tr("Recent Documents"))
            if pageRecentFile != None:
                pageRecentFile.setSize(9)
                self.connect(pageRecentFile, QtCore.SIGNAL("openRecentFile(const QString&)"), self.openRecentFile)
                #self.connect(self, SIGNAL(updateRecentFileActions(const QStringList&)),
                #    pageRecentFile, SLOT(updateRecentFileActions(const QStringList&)));

    def createQuickAccessBar(self):
        quickAccessBar = self.ribbonBar().quickAccessBar()
        action = quickAccessBar.actionCustomizeButton()
        action.setToolTip(self.tr("Customize Quick Access Bar"))

        smallButton = quickAccessBar.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_New), self.tr("New"))
        smallButton.setToolTip(self.tr("Create a new document"))
        self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)
        quickAccessBar.setActionVisible(smallButton, False)

        smallButton = quickAccessBar.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Open), self.tr("Open"))
        smallButton.setToolTip(self.tr("Open an existing document"))
        self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)
        quickAccessBar.setActionVisible(smallButton, False)

        smallButton = quickAccessBar.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Save), self.tr("Save"))
        smallButton.setToolTip(self.tr("Save the active document"))
        self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

        smallButton = quickAccessBar.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Undo), self.tr("&Undo"))
        smallButton.setShortcut(QKeySequence.Undo)
        smallButton.setEnabled(False)

        smallButton = quickAccessBar.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Redo), self.tr("&Redo"))
        smallButton.setShortcut(QKeySequence.Redo)
        smallButton.setEnabled(False)

        quickAccessBar.setVisible(True)

    def createRibbon(self):
        pageButtons = self.ribbonBar().addPage(self.tr("&Buttons"))

        if pageButtons:
            splitPopup = QMenu(self.ribbonBar())
            self.connect(splitPopup.addAction(self.tr("Option 1")), QtCore.SIGNAL("triggered()"), self.pressButton)
            self.connect(splitPopup.addAction(self.tr("Option 2")), QtCore.SIGNAL("triggered()"), self.pressButton)
            self.connect(splitPopup.addAction(self.tr("Option 3")), QtCore.SIGNAL("triggered()"), self.pressButton)

            iconSplit = QIcon()
            iconSplit.addPixmap(QPixmap(":/res/largeSplitButton.png"))
            iconSplit.addPixmap(QPixmap(":/res/smallSplitButton.png"))

            iconButtton = QIcon()
            iconButtton.addPixmap(QPixmap(":/res/largeButton.png"))
            iconButtton.addPixmap(QPixmap(":/res/smallButton.png"))

            iconPopupButtton = QIcon()
            iconPopupButtton.addPixmap(QPixmap(":/res/largePopupButton.png"))
            iconPopupButtton.addPixmap(QPixmap(":/res/smallPopupButton.png"))

            # Large Buttons
            groupClipboard = pageButtons.addGroup(self.tr("&Large Buttons"))
            if groupClipboard:
                groupClipboard.setOptionButtonVisible(True)
                action = groupClipboard.optionButtonAction()
                action.setToolTip(self.tr("Large Buttons"))
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

                action = groupClipboard.addAction(iconButtton, self.tr("&Button"), Qt.ToolButtonTextUnderIcon)
                control = groupClipboard.controlByAction(action)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

                action = groupClipboard.addAction(QIcon(":/res/Edit.Create.svg"), self.tr("Button &SVG"), Qt.ToolButtonTextUnderIcon)
                control = groupClipboard.controlByAction(action)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

                action = groupClipboard.addAction(QIcon(":/res/largeToggleButton.png"), self.tr("Toggle Button"), Qt.ToolButtonTextUnderIcon)
                action.setCheckable(True)
                action.setChecked(True)
                control = groupClipboard.controlByAction(action)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)

                menuPopup = groupClipboard.addMenu(iconPopupButtton, self.tr("Popup Button"), Qt.ToolButtonTextUnderIcon)
                control = groupClipboard.controlByAction(menuPopup.defaultAction())
                control.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)

                self.connect(menuPopup.addAction(self.tr("Option 1")), QtCore.SIGNAL("triggered()"), self.pressButton)
                self.connect(menuPopup.addAction(self.tr("Option 2")), QtCore.SIGNAL("triggered()"), self.pressButton)
                self.connect(menuPopup.addAction(self.tr("Option 3")), QtCore.SIGNAL("triggered()"), self.pressButton)

                action = groupClipboard.addAction(iconSplit, self.tr("S&plit Button"), Qt.ToolButtonTextUnderIcon, splitPopup)
                control = groupClipboard.controlByAction(action)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                control.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

            # Small Buttons
            groupSmallButtons = pageButtons.addGroup(self.tr("Small Buttons"))
            if groupSmallButtons:
                groupSmallButtons.setOptionButtonVisible(True)
                action = groupSmallButtons.optionButtonAction()
                action.setText(self.tr("S&mall"))
                action.setToolTip(self.tr("Small Buttons"))
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = groupSmallButtons.addAction(iconButtton, self.tr("B&utton"), Qt.ToolButtonTextBesideIcon)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                menuPopup = groupSmallButtons.addMenu(iconPopupButtton, self.tr("Popup Button"), Qt.ToolButtonTextBesideIcon)
                menuPopup.addAction(self.tr("Option &1"))
                menuPopup.addAction(self.tr("Option &2"))
                menuPopup.addAction(self.tr("Option &3"))

                smallButton = groupSmallButtons.addAction(iconSplit, self.tr("Split Button"), Qt.ToolButtonTextBesideIcon, splitPopup)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = groupSmallButtons.addAction(iconButtton, self.tr("B&utton"), Qt.ToolButtonIconOnly)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                menuPopup = groupSmallButtons.addMenu(iconPopupButtton, self.tr("Popup Button"), Qt.ToolButtonIconOnly)
                menuPopup.addAction(self.tr("Option &1"))
                menuPopup.addAction(self.tr("Option &2"))
                menuPopup.addAction(self.tr("Option &3"))

                smallButton = groupSmallButtons.addAction(iconSplit, self.tr("Split Button"), Qt.ToolButtonIconOnly, splitPopup)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

            # CheckBoxes and Radio Buttons
            groupCheckboxButtons = pageButtons.addGroup(self.tr("Checkboxes && Radio Buttons"));
            if groupCheckboxButtons:
                groupCheckboxButtons.setOptionButtonVisible(True)
                groupCheckboxButtons.setContentAlignment(Qt.AlignVCenter)

                action = groupCheckboxButtons.optionButtonAction()
                action.setToolTip(self.tr("Checkboxes && Radio Buttons"))
                self.connect(action, QtCore.SIGNAL("triggered()"), self.pressButton)

                checkBoxControl = RibbonCheckBoxControl(self.tr("CheckBox 1"))
                groupCheckboxButtons.addControl(checkBoxControl)
                check1 = checkBoxControl.widget()
                check1.setToolTip(self.tr("CheckBox 1"))
                check1.setCheckState(Qt.Checked)

                checkBoxControl = RibbonCheckBoxControl(self.tr("CheckBox 2"))
                groupCheckboxButtons.addControl(checkBoxControl)
                check2 = checkBoxControl.widget()
                check2.setToolTip(self.tr("CheckBox 2"))
                check2.setCheckState(Qt.Unchecked)

                checkBoxControl = RibbonCheckBoxControl(self.tr("CheckBox 3"))
                groupCheckboxButtons.addControl(checkBoxControl)
                check3 = checkBoxControl.widget()
                check3.setToolTip(self.tr("CheckBox 3"))
                check3.setCheckState(Qt.PartiallyChecked)

                groupCheckboxButtons.addSeparator()

                groupButton = QButtonGroup(self)
                radioButtonControl = RibbonRadioButtonControl(self.tr("Radio Button 1"));
                groupCheckboxButtons.addControl(radioButtonControl)
                radio1 = radioButtonControl.widget()
                groupButton.addButton(radio1)
                radio1.setToolTip(self.tr("Radio Button 1"))
                radio1.setChecked(True)

                radioButtonControl = RibbonRadioButtonControl(self.tr("Radio Button 2"))
                groupCheckboxButtons.addControl(radioButtonControl)
                radio2 = radioButtonControl.widget()
                groupButton.addButton(radio2)
                radio2.setToolTip(self.tr("Radio Button 2"))

                radioButtonControl = RibbonRadioButtonControl(self.tr("Radio Button 3"))
                groupCheckboxButtons.addControl(radioButtonControl)
                radio3 = radioButtonControl.widget()
                groupButton.addButton(radio3)
                radio3.setToolTip(self.tr("Radio Button 3"))

            # Groups
            groupGroups = pageButtons.addGroup(self.tr("Groups"))
            if groupGroups:
                groupGroups.setContentAlignment(Qt.AlignVCenter)

                toolBarControl = RibbonToolBarControl(groupGroups)
                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_New), self.tr("New"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Create a new document"))
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Open), self.tr("Open"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Open an existing document"))
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Save), self.tr("Save"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Save the active document"))
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Cut), self.tr("Cut"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Cut the selection and put it on the Clipboard"))
                smallButton.setEnabled(False)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(QIcon(":/res/smallCopy.png"), self.tr("Copy"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Copy the selection and put it on the Clipboard"))
                smallButton.setEnabled(False)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Clipboard), self.tr("Paste"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Insert Clipboard contents"))
                smallButton.setEnabled(False)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                toolBarControl.addSeparator()

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Undo), self.tr("Undo"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Undo the last action"))
                smallButton.setEnabled(False)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(DemoRibbonWindow.createIcon(DemoRibbonWindow.Image_Redo), self.tr("Redo"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Redo the previously undone action"))
                smallButton.setEnabled(False)
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                toolBarControl.addSeparator()

                smallButton = toolBarControl.addAction(QIcon(":/res/smallPrint.png"), self.tr("Print"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Print the active document"))
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.pressButton)

                smallButton = toolBarControl.addAction(QIcon(":/shared/res/about.png"), self.tr("About"), Qt.ToolButtonIconOnly)
                smallButton.setToolTip(self.tr("Display program information, version number and copyright"))
                self.connect(smallButton, QtCore.SIGNAL("triggered()"), self.about)

                groupGroups.addControl(toolBarControl)

            # Groups
            testGroups = pageButtons.addGroup(self.tr("Test"))
            if testGroups:
                icon = QIcon()
                icon.addPixmap(QPixmap(":/res/test16x16.png"))
                icon.addPixmap(QPixmap(":/res/test32x32.png"))
                icon.addPixmap(QPixmap(":/res/test64x64.png"))
                icon.addPixmap(QPixmap(":/res/test128x128.png"))
                actionTest = testGroups.addAction(icon, self.tr("Button &Test"), Qt.ToolButtonTextUnderIcon)
                controlTest = testGroups.controlByAction(actionTest)
                controlTest.sizeDefinition(RibbonControlSizeDefinition.GroupLarge).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                controlTest.sizeDefinition(RibbonControlSizeDefinition.GroupMedium).setImageSize(RibbonControlSizeDefinition.ImageLarge)
                controlTest.sizeDefinition(RibbonControlSizeDefinition.GroupSmall).setImageSize(RibbonControlSizeDefinition.ImageLarge)

                actionTest = testGroups.addAction(icon, self.tr("Button &Test"), Qt.ToolButtonTextBesideIcon)
                menuPopup = testGroups.addMenu(icon, self.tr("Popup Test"), Qt.ToolButtonTextBesideIcon)
                menuPopup.addAction(self.tr("Option &1"))
                menuPopup.addAction(self.tr("Option &2"))
                menuPopup.addAction(self.tr("Option &3"))
                testGroups.addAction(icon, self.tr("Split Test"), Qt.ToolButtonTextBesideIcon, splitPopup)

        pageEditors = self.ribbonBar().addPage(self.tr("&Editors"))
        if pageEditors:
            groupStandard = pageEditors.addGroup(self.tr("Standard"))
            if groupStandard:
                lineEditControl = RibbonLineEditControl()
                groupStandard.addControl(lineEditControl)
                controlEdit = lineEditControl.widget()
                controlEdit.setToolTip(self.tr("Edit"))
                controlEdit.setText(self.tr("Edit"))

                comboBoxControl = RibbonComboBoxControl()
                groupStandard.addControl(comboBoxControl)
                controlComboBox = comboBoxControl.widget()
                controlComboBox.setToolTip(self.tr("Combo"))
                controlComboBox.setEditable(True)
                controlComboBox.addItem(self.tr("ComboBox"))
                controlComboBox.addItem(self.tr("Item 1"))
                controlComboBox.addItem(self.tr("Item 2"))
                controlComboBox.addItem(self.tr("Item 3"))

                comboBoxControl = RibbonComboBoxControl()
                groupStandard.addControl(comboBoxControl)
                controlComboBox = comboBoxControl.widget()
                controlComboBox.setToolTip(self.tr("Combo"))
                controlComboBox.addItem(self.tr("ComboBox"))
                controlComboBox.addItem(self.tr("Item 1"))
                controlComboBox.addItem(self.tr("Item 2"))

            groupExtendedEditors = pageEditors.addGroup(self.tr("Extended"))
            if groupExtendedEditors:
                spinBoxControl = RibbonSpinBoxControl()
                groupExtendedEditors.addControl(spinBoxControl)
                spinBox = spinBoxControl.widget()
                spinBox.setToolTip(self.tr("Edit"))
                spinBox.setMaximumWidth(150)
                spinBox.setMinimumWidth(150)
                action = QWidgetAction(self)
                action.setText(self.tr("Edit:"))
                action.setIcon(QIcon(":/res/smallEditor.png"))
                spinBoxControl.setDefaultAction(action)

                comboBoxControl = RibbonComboBoxControl()
                groupExtendedEditors.addControl(comboBoxControl)
                controlComboBox = comboBoxControl.widget()
                controlComboBox.setMaximumWidth(150)
                controlComboBox.setMinimumWidth(150)
                controlComboBox.setToolTip(self.tr("ComboBox"))
                controlComboBox.setEditable(True)
                controlComboBox.addItem(self.tr("ComboBox"))
                controlComboBox.addItem(self.tr("Item 1"))
                controlComboBox.addItem(self.tr("Item 2"))
                action = QWidgetAction(self)
                action.setText(self.tr("Combo:"))
                action.setIcon(QIcon(":/res/smallComboBox.png"))
                comboBoxControl.setDefaultAction(action)

                comboBoxControl = RibbonComboBoxControl()
                groupExtendedEditors.addControl(comboBoxControl)
                controlComboBox = comboBoxControl.widget()
                controlComboBox.setMaximumWidth(150)
                controlComboBox.setMinimumWidth(150)
                controlComboBox.setToolTip(self.tr("ComboBox"))
                controlComboBox.setEditable(True)
                controlComboBox.addItem(self.tr("ComboBox"))
                controlComboBox.addItem(self.tr("Item 1"))
                controlComboBox.addItem(self.tr("Item 2"))
                action = QWidgetAction(self)
                action.setText(self.tr("Combo:"))
                action.setIcon(QIcon(":/res/smallComboBox.png"))
                comboBoxControl.setDefaultAction(action)

            groupDateTime = pageEditors.addGroup(self.tr("Date/Time"))
            if groupDateTime:
                timeEdit = RibbonTimeEditControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Time:"))
                timeEdit.setDefaultAction(action)
                groupDateTime.addControl(timeEdit)

                dateEdit = RibbonDateEditControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Date 1:"))
                dateEdit.setDefaultAction(action)
                groupDateTime.addControl(dateEdit)

                dateEdit = RibbonDateEditControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Date 2:"))
                dateEdit.setDefaultAction(action)
                dateEdit.setCalendarPopup(True)
                groupDateTime.addControl(dateEdit)

                groupDateTime.addSeparator()

                dateComboBox = RibbonDateTimeEditControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Date/Time 1:"))
                dateComboBox.setDefaultAction(action)
                groupDateTime.addControl(dateComboBox)

                dateComboBox = RibbonDateTimeEditControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Date/Time 2:"))
                dateComboBox.setDefaultAction(action)
                dateComboBox.setCalendarPopup(True)
                groupDateTime.addControl(dateComboBox)

            groupGallery = pageEditors.addGroup(self.tr("Gallery"))
            if groupGallery:
                fontComboBox = RibbonFontComboBoxControl()
                action = QWidgetAction(self)
                action.setText(self.tr("Font:"))
                fontComboBox.setDefaultAction(action)
                groupGallery.addControl(fontComboBox)

                comboFont = fontComboBox.widget()
                comboFont.setFontFilters(QFontComboBox.MonospacedFonts)
                if comboFont.count() > 0:
                    comboFont.setCurrentIndex(0)
                else:
                    comboFont.setEditText(self.tr(""))

        pageMisc = self.ribbonBar().addPage(self.tr("&Misc"))
        if pageMisc:
            groupLable = pageMisc.addGroup(self.tr("Label"))
            groupLable.addControl(RibbonLabelControl(self.tr("Label Text 1")))
            groupLable.addControl(RibbonLabelControl(self.tr("Label Text 2")))
            groupLable.addControl(RibbonLabelControl(self.tr("Label Text 3")))

            groupBitmap = pageMisc.addGroup(self.tr("Bitmap"))
            groupBitmap.setContentAlignment(Qt.AlignVCenter)
            labelControl = RibbonLabelControl()
            groupBitmap.addControl(labelControl)
            label = labelControl.widget()
            label.setPixmap(QPixmap(":/res/Windows.png"))

            groupBitmapLinux = pageMisc.addGroup(self.tr("Bitmap"))
            groupBitmapLinux.setContentAlignment(Qt.AlignVCenter)
            labelControl = RibbonLabelControl()
            groupBitmapLinux.addControl(labelControl)
            pLabel = labelControl.widget()
            pLabel.setPixmap(QPixmap(":/res/linux.png"))

            groupProgressBar = pageMisc.addGroup(self.tr("ProgressBar"))
            groupProgressBar.setContentAlignment(Qt.AlignVCenter)
            self.progressBar = QProgressBar()
            self.progressBar.setAlignment(Qt.AlignHCenter)
            self.progressBar.setRange(0, 100)
            self.progressBar.setValue(40)
            self.progressBar.setMinimumWidth(100)
            self.progressBar.setMaximumHeight(22)
            groupProgressBar.addWidget(self.progressBar)

            self.progressBar1 = QProgressBar()
            self.progressBar1.setTextVisible(False)
            self.progressBar1.setRange(0, 100)
            self.progressBar1.setValue(40)
            self.progressBar1.setMinimumWidth(100)
            self.progressBar1.setMaximumHeight(22)
            groupProgressBar.addWidget(self.progressBar1)

            checkBoxControl = RibbonCheckBoxControl(self.tr("Animation bar"))
            groupProgressBar.addControl(checkBoxControl)
            checkAnimationBar = checkBoxControl.widget()
            self.connect(checkAnimationBar, QtCore.SIGNAL("stateChanged(int)"), self.startProgressBar);
            checkAnimationBar.setCheckState(Qt.Unchecked)

            groupScrollBar = pageMisc.addGroup(self.tr("ScrollBar"))
            groupScrollBar.setContentAlignment(Qt.AlignVCenter)

            scrollBar = QScrollBar(Qt.Horizontal)
            scrollBar.setMinimumWidth(100)
            scrollBar.setMaximumHeight(18)
            scrollBar.setMinimum(0)
            scrollBar.setMaximum(20)
            groupScrollBar.addWidget(scrollBar)

            groupSlider = pageMisc.addGroup(self.tr("Slider"))
            groupSlider.setContentAlignment(Qt.AlignVCenter)

            sliderPaneControl = RibbonSliderPaneControl()
            groupSlider.addControl(sliderPaneControl)
            sliderPane = sliderPaneControl.widget()
            sliderPane.setScrollButtons(True)
            sliderPane.setRange(0, 100)
            sliderPane.setSingleStep(10)
            sliderPane.setSliderPosition(50)

            sliderControl = RibbonSliderControl(Qt.Horizontal)
            groupSlider.addControl(sliderControl)
            slider = sliderControl.widget()
            slider.setRange(0, 100)
            slider.setTickPosition(QSlider.TicksLeft)
            slider.setTickInterval(20)
            slider.setSingleStep(10)
            slider.setSliderPosition(50)
            self.connect(sliderPane, QtCore.SIGNAL("valueChanged(int)"), slider, QtCore.SLOT("setValue(int)"))
            self.connect(slider, QtCore.SIGNAL("valueChanged(int)"), sliderPane, QtCore.SLOT("setValue(int)"))

            sliderControl = RibbonSliderControl(Qt.Horizontal)
            groupSlider.addControl(sliderControl)
            slider = sliderControl.widget()
            slider.setTickPosition(QSlider.TicksRight)
            slider.setTickInterval(20)

            groupSlider.addSeparator()

            sliderControl = RibbonSliderControl(Qt.Vertical)
            groupSlider.addControl(sliderControl)
            slider = sliderControl.widget()
            slider.setTickPosition(QSlider.TicksLeft)
            slider.setTickInterval(20)

            sliderControl = RibbonSliderControl(Qt.Vertical)
            groupSlider.addControl(sliderControl)
            slider = sliderControl.widget()
            slider.setTickPosition(QSlider.TicksRight)
            slider.setTickInterval(20)

            groupSlider.addSeparator()

            sliderControl = RibbonSliderControl(Qt.Vertical)
            groupSlider.addControl(sliderControl)
            slider = sliderControl.widget()

        contextPage = self.ribbonBar().addPage(self.tr("&Context Tab"))
        if contextPage:
            self.contextPage = contextPage
            self.contextPage.setContextColor(Qtitan.ContextColorRed)

            groupContextColor = self.contextPage.addGroup(self.tr("Context Color"))
            groupColorButton = QButtonGroup(self)
            self.connect(groupColorButton, QtCore.SIGNAL("buttonClicked(QAbstractButton*)"), self.buttonColorClicked)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Green"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorGreen)
            radio.setToolTip(self.tr("Color Green"))
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Blue"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorBlue)
            radio.setToolTip(self.tr("Color Blue"))
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Red"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorRed)
            radio.setToolTip(self.tr("Color Red"))
            radio.setChecked(True)
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Yellow"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorYellow)
            radio.setToolTip(self.tr("Color Yellow"))
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Cyan"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorCyan)
            radio.setToolTip(self.tr("Color Cyan"))
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Purple"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorPurple)
            radio.setToolTip(self.tr("Color Purple"))
            groupColorButton.addButton(radio)

            radioButtonControl = RibbonRadioButtonControl(self.tr("Orange"))
            groupContextColor.addControl(radioButtonControl)
            radio = radioButtonControl.widget()
            radio.setProperty(self.Prop_ContextColor, Qtitan.ContextColorOrange)
            radio.setToolTip(self.tr("Color Orange"))
            groupColorButton.addButton(radio)

        #self.ribbonBar().setTitleBarVisible(False)
        self.ribbonBar().setFrameThemeEnabled()
        #setButtonStyleTheme(self.ribbonStyle.getTheme());

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

    def open(self):
        fileName = QFileDialog.getOpenFileName(self, self.tr("Open"))[0]
        if not fileName:
            return False
        self.setCurrentFile(fileName)
        self.statusBar().showMessage(self.tr("File loaded"), 2000)
        return True

    def save(self):
        fileName = QFileDialog.getSaveFileName(self, self.tr("Save As"), self.tr("Document"), "*.txt")[0]
        if not fileName:
            return False
        self.setCurrentFile(fileName)
        self.statusBar().showMessage(self.tr("File saved"), 2000)
        return True

    def openRecentFile(self, file):
        QMessageBox.information(self, self.windowTitle(), "Open Recent File. " + file, QMessageBox.Ok)

    def print(self):
        printer = QPrinter()
        dialog = QPrintDialog(printer, self)
        dialog.exec()

    def printSetup(self):
        printer = QPrinter()

    def pressButton(self):
        QMessageBox.information(self, self.windowTitle(), "Press button.", QMessageBox.Ok)

    def startProgressBar(self, state):
        if Qt.CheckState(state) == Qt.Checked:
            self.progressBar2 = QProgressBar()
            self.progressBar2.setMaximumWidth(200)
            height = self.statusBar().sizeHint().height()
            self.progressBar2.setMaximumHeight(height - height / 3)
            self.statusBar().addPermanentWidget(self.progressBar2)
            self.valueProgress = 0
            self.timerProgressBar.start()
        elif Qt.CheckState(state) == Qt.Unchecked:
            self.timerProgressBar.stop()
            self.valueProgress = 40
            self.progressBar.setValue(self.valueProgress)
            self.progressBar1.setValue(self.valueProgress)
            self.progressBar2.setValue(self.valueProgress)
            self.statusBar().removeWidget(self.progressBar2)
            self.progressBar2 = None

    @QtCore.Slot()
    def animateProgressBar(self):
        self.progressBar.setValue(self.valueProgress)
        self.progressBar1.setValue(self.valueProgress)
        self.progressBar2.setValue(self.valueProgress)

        self.valueProgress += 10

        if self.valueProgress == 100:
            self.progressBar.setValue(self.valueProgress)
            self.progressBar1.setValue(self.valueProgress)
            self.progressBar2.setValue(self.valueProgress)
            self.valueProgress = 0

    def buttonColorClicked(self, button):
        numColor = button.property(self.Prop_ContextColor).toUInt()
        self.contextPage.setContextColor(Qtitan.ContextColor(numColor))

    def setCurrentFile(self, fileName):
        self.setWindowFilePath(fileName)
        settings = QSettings(QSettings.UserScope, "Developer Machines")
        files = settings.value("recentFileList").toStringList()
        files.removeAll(fileName)
        files.prepend(fileName)
        while files.size() > 9:
            files.removeLast()
        settings.setValue("recentFileList", files)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setApplicationName("PyQtitanRibbon Controls");
    app.setOrganizationName("Developer Machines");
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())