DynamicPanels 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, DockPanelRequestedArgs

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt, QTimer, QSize, QPointF, QRectF, QRect
    from PySide2.QtGui import QIcon, QKeySequence, QLinearGradient, QColor, QBrush, QPen, QFont, QPainter
    from PySide2.QtWidgets import (QAction, QApplication, QTreeWidgetItem, QTreeWidget, QTableWidget, QTableWidgetItem,
        QMdiArea, QTextEdit, QLabel, QDialog, QOpenGLWidget, QAbstractItemView)

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt, QTimer, QSize, QPointF, QRectF, QRect
    from PySide6.QtGui import QAction, QIcon, QKeySequence, QLinearGradient, QColor, QBrush, QPen, QFont, QPainter
    from PySide6.QtWidgets import (QApplication, QTreeWidgetItem, QTreeWidget, QTableWidget, QTableWidgetItem,
        QMdiArea, QTextEdit, QLabel, QDialog, QAbstractItemView)
    from PySide6.QtOpenGLWidgets import QOpenGLWidget

from DemoDockWindow import DemoDockWindow

import DynamicPanels_rc

from ui_DynamicPanelsDialogForm import Ui_DialogForm as ui

class DialogForm(QDialog):
    def __init__(self):
        QDialog.__init__(self)
        self.ui = ui()
        self.ui.setupUi(self)

class Helper():
    def __init__(self, num):
        gradient = QLinearGradient(QPointF(50, -20), QPointF(80, 20))
        gradient.setColorAt(0.0, QColor(0xFF, 0x00, 0x00))
        gradient.setColorAt(1.0, QColor(0x73, 0x20, 0x1B))

        self.background = QBrush(QColor(46, 46, 46))
        self.circleBrush = QBrush(gradient)
        self.circlePen = QPen(Qt.black)
        self.circlePen.setWidth(1)
        self.textPen = QPen(Qt.white)

        self.textFont = QFont()
        self.textFont.setPixelSize(50)
        self.number = num

    def paint(self, painter, event, elapsed):
        painter.fillRect(event.rect(), self.background)
        painter.translate(event.rect().width()/2, event.rect().height()/2)
        painter.save()
        painter.setBrush(self.circleBrush)
        painter.setPen(self.circlePen)
        painter.rotate(elapsed * 0.030)

        r = elapsed / 1000.0
        n = 40
        for i in range(0, n):
            painter.rotate(30)
            factor = (i + r) / n
            radius = 0 + 180.0 * factor
            circleRadius = 1 + factor * 20
            painter.drawEllipse(QRectF(radius, -circleRadius, circleRadius * 2, circleRadius * 2))

        painter.restore()
        painter.setPen(self.textPen)
        painter.setFont(self.textFont)
        painter.drawText(QRect(-90, -50, 190, 100), Qt.AlignCenter, "Qtitan {}".format(self.number))

class GLWidget(QOpenGLWidget):
    def __init__(self, num, parent = None):
        QOpenGLWidget.__init__(self, parent)
        self.helper = Helper(num)
        self.elapsed = 0
        self.setAutoFillBackground(False)
        self.timer = QTimer(self)
        self.connect(self.timer, QtCore.SIGNAL("timeout()"), self, QtCore.SLOT("animate()"))
        self.timer.start(50)

    def animate(self):
        self.elapsed = (self.elapsed + self.sender().interval()) % 1000
        self.update()

    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        self.helper.paint(painter, event, self.elapsed)
        painter.end()

class MainWindow(DemoDockWindow):
    def __init__(self):
        DemoDockWindow.__init__(self)
        self.mdiArea = QMdiArea()
        self.numberForm = 0
        self.numberTree = 0
        self.numberTable = 0
        self.numberOpenGL = 0
        self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setCentralWidget(self.mdiArea)

        self.dockPanelManager().setDockPanelTransparentWhileDragging(True)
        self.dockPanelManager().setArrowMarkersShown(True)
        self.dockPanelManager().setDockPanelFullContentsWhileDraggingShown(True)
        self.connect(self.dockPanelManager(), QtCore.SIGNAL("panelRequested(DockPanelRequestedArgs*)"), self,
                     QtCore.SLOT("panelRequested(DockPanelRequestedArgs*)"))

        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)

    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.filePrintAction = QAction(QIcon(":/res/print16x16.png"), self.tr("Print"), self)
        self.filePrintAction.setStatusTip(self.tr("Print the active document"))
        self.filePrintAction.setDisabled(True)
        self.filePrintAction.setDisabled(True)

        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.editCutAction.setDisabled(True)

        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.editCopyAction.setDisabled(True)

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

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

        self.createFormAction = QAction(self.tr("Form"), self)
        self.connect(self.createFormAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateForm()"))
        self.createTreeAction = QAction(self.tr("Tree"), self)
        self.connect(self.createTreeAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateTree()"))
        self.createTableAction = QAction(self.tr("Table"), self)
        self.connect(self.createTableAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateTable()"))
        self.createOpenGLAction = QAction(self.tr("OpenGL"), self)
        self.connect(self.createOpenGLAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateOpenGL()"))

        self.createThreeRowAction = QAction(self.tr("Three Rows"), self)
        self.connect(self.createThreeRowAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateThreeRows()"))
        self.createThreeColumnAction  = QAction(self.tr("Three Columns"), self)
        self.connect(self.createThreeColumnAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateThreeColumns()"))
        self.createThreeTabsAction = QAction(self.tr("Three Tabs"), self)
        self.connect(self.createThreeTabsAction, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("slot_CreateThreeTabs()"))

    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu(self.tr("&Create"))
        self.fileMenu.addAction(self.createFormAction)
        self.fileMenu.addAction(self.createTreeAction)
        self.fileMenu.addAction(self.createTableAction)
        self.fileMenu.addAction(self.createOpenGLAction)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.createThreeRowAction)
        self.fileMenu.addAction(self.createThreeColumnAction)
        self.fileMenu.addAction(self.createThreeTabsAction)

        self.editMenu = self.menuBar().addMenu(self.tr("&Edit"))
        self.viewMenu = self.menuBar().addMenu(self.tr("&View"))
        self.addSaveLoadMenu(self.viewMenu)
        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.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.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)

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

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

    def slot_CreateForm(self):
        form = self.createFormPanel()
        self.insertDockPanel(form, QSize(220, 200), Qtitan.RightDockPanelArea)

    def slot_CreateTree(self):
        tree = createTreePanel()
        self.insertDockPanel(tree, QSize(220, 200), Qtitan.LeftDockPanelArea)

    def slot_CreateTable(self):
        table = self.createTablePanel()
        self.insertDockPanel(table, QSize(220, 200), Qtitan.BottomDockPanelArea)

    def slot_CreateOpenGL(self):
        openGL = self.createOpenGLPanel()
        self.insertDockPanel(openGL, QSize(220, 200), Qtitan.LeftDockPanelArea)

    def slot_CreateThreeRows(self):
        form = self.createFormPanel()
        tree = self.createTreePanel()
        table = self.createTablePanel()
        self.insertDockPanel(form, QSize(220, 200), Qtitan.BottomDockPanelArea)
        self.insertDockPanel(tree, QSize(220, 200), Qtitan.RightDockPanelArea, form)
        self.insertDockPanel(table, QSize(220, 200), Qtitan.RightDockPanelArea, form)

    def slot_CreateThreeColumns(self):
        form = self.createFormPanel()
        tree = self.createTreePanel()
        table = self.createTablePanel()
        self.insertDockPanel(form, QSize(220, 200), Qtitan.LeftDockPanelArea)
        self.insertDockPanel(tree, QSize(220, 200), Qtitan.BottomDockPanelArea, form)
        self.insertDockPanel(table, QSize(220, 200), Qtitan.BottomDockPanelArea, form)

    def slot_CreateThreeTabs(self):
        form = self.createFormPanel()
        tree = self.createTreePanel()
        table = self.createTablePanel()
        self.insertDockPanel(form, QSize(220, 200), Qtitan.RightDockPanelArea)
        self.insertDockPanel(tree, QSize(220, 200), Qtitan.InsideDockPanelArea, form)
        self.insertDockPanel(table, QSize(220, 200), Qtitan.InsideDockPanelArea, form)

    def createFormPanel(self):
        panel = DockWidgetPanel("Form {0}".format(self.numberForm), self.dockPanelManager())
        self.numberForm = self.numberForm + 1
        dialog = DialogForm()
        panel.setWidget(dialog)
        return panel

    def createTreePanel(self):
        panel = DockWidgetPanel("Tree {0}".format(self.numberTree), self.dockPanelManager())
        self.numberTree = self.numberTree + 1
        treeWidget = QTreeWidget()
        treeWidget.setAlternatingRowColors(True)
        treeWidget.setMinimumWidth(190)
        treeWidget.setHeaderHidden(True)

        strings = []
        strings.append("Item 1")
        mainItem = QTreeWidgetItem(strings)
        mainItem.setCheckState(0, Qt.Checked)
        mainItem.setExpanded(False)
        mainItem.setIcon(0, QIcon(":/res/open16x16.png"))
        treeWidget.insertTopLevelItem(0, mainItem)

        strings = []
        strings.append("Item 2")
        item = QTreeWidgetItem(mainItem, strings)
        item.setCheckState(0, Qt.Checked)
        item.setIcon(0, QIcon(":/res/open16x16.png"))
        item.setExpanded(True)
        treeWidget.insertTopLevelItem(1, item)

        strings = []
        strings.append("Item 3")
        item = QTreeWidgetItem(mainItem, strings)
        item.setCheckState(0, Qt.Checked)
        item.setIcon(0, QIcon(":/res/open16x16.png"))
        item.setExpanded(True)
        treeWidget.insertTopLevelItem(1, item)

        strings = []
        strings.append("Item 4")
        item = QTreeWidgetItem(mainItem, strings)
        item.setCheckState(0, Qt.Checked)
        item.setIcon(0, QIcon(":/res/open16x16.png"))
        item.setExpanded(True)
        treeWidget.insertTopLevelItem(1, item)

        strings = []
        strings.append("Item 5")
        item = QTreeWidgetItem(mainItem, strings)
        item.setCheckState(0, Qt.Checked)
        item.setIcon(0, QIcon(":/res/open16x16.png"))
        item.setExpanded(True)
        treeWidget.insertTopLevelItem(1, item)

        strings = []
        strings.append("Item 6")
        item = QTreeWidgetItem(mainItem, strings)
        item.setCheckState(0, Qt.Checked)
        item.setIcon(0, QIcon(":/res/open16x16.png"))
        item.setExpanded(True)
        treeWidget.insertTopLevelItem(1, item)
        treeWidget.expandAll()

        panel.setWidget(treeWidget)
        return panel

    def createTablePanel(self):
        panel = DockWidgetPanel("Table {0}".format(self.numberTable), self.dockPanelManager())

        self.numberTable = self.numberTable + 1
        tableWidget = QTableWidget()
        tableWidget.setAlternatingRowColors(True)

        tableWidget.setColumnCount(11)
        tableWidget.setRowCount(6)
        tableWidget.setShowGrid(False)
        tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
        tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        tableWidget.setSelectionMode(QAbstractItemView.SingleSelection)

        tableWidget.setHorizontalHeaderItem(0, QTableWidgetItem(self.tr("Name")))
        tableWidget.setHorizontalHeaderItem(1, QTableWidgetItem(self.tr("Path")))
        tableWidget.setHorizontalHeaderItem(2, QTableWidgetItem(self.tr("Optimized")))
        tableWidget.setHorizontalHeaderItem(3, QTableWidgetItem(self.tr("User Code")))
        tableWidget.setHorizontalHeaderItem(4, QTableWidgetItem(self.tr("Symbol Status")))
        tableWidget.setHorizontalHeaderItem(5, QTableWidgetItem(self.tr("Symbol File")))
        tableWidget.setHorizontalHeaderItem(6, QTableWidgetItem(self.tr("Order")))
        tableWidget.setHorizontalHeaderItem(7, QTableWidgetItem(self.tr("Version")))
        tableWidget.setHorizontalHeaderItem(8, QTableWidgetItem(self.tr("Timestamp")))
        tableWidget.setHorizontalHeaderItem(9, QTableWidgetItem(self.tr("Addresswewe")))
        tableWidget.setHorizontalHeaderItem(10, QTableWidgetItem(self.tr("Process")))

        height = tableWidget.horizontalHeader().sizeHint().height()

        tableWidget.setRowHeight(0, height)
        tableWidget.setVerticalHeaderItem(0, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(0, 0, QTableWidgetItem("ntdll.dll"))
        tableWidget.setItem(0, 1, QTableWidgetItem("C:/Windows/System32/ntdll.dll"))
        tableWidget.setItem(0, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(0, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(0, 4, QTableWidgetItem("Symbols loaded."))
        tableWidget.setItem(0, 5, QTableWidgetItem("C:/Qtitan/customstyles.pdb"))
        tableWidget.setItem(0, 6, QTableWidgetItem("1"))
        tableWidget.setItem(0, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(0, 8, QTableWidgetItem("27.10.2010 8:32"))
        tableWidget.setItem(0, 9, QTableWidgetItem("773A0000-774DD000"))
        tableWidget.setItem(0, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        tableWidget.setRowHeight(1, height)
        tableWidget.setVerticalHeaderItem(1, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(1, 0, QTableWidgetItem("ntdll.dll"))
        tableWidget.setItem(1, 1, QTableWidgetItem("C:/Windows/System32/kernel32.dll"))
        tableWidget.setItem(1, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(1, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(1, 4, QTableWidgetItem("No symbols loaded."))
        tableWidget.setItem(1, 5, QTableWidgetItem(""))
        tableWidget.setItem(1, 6, QTableWidgetItem("2"))
        tableWidget.setItem(1, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(1, 8, QTableWidgetItem("27.10.2010 8:32"))
        tableWidget.setItem(1, 9, QTableWidgetItem("872A0000-766DD000"))
        tableWidget.setItem(1, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        tableWidget.setRowHeight(2, height)
        tableWidget.setVerticalHeaderItem(2, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(2, 0, QTableWidgetItem("kernelBase.dll"))
        tableWidget.setItem(2, 1, QTableWidgetItem("C:/Windows/System32/kernelBase.dll"))
        tableWidget.setItem(2, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(2, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(2, 4, QTableWidgetItem("No symbols loaded."))
        tableWidget.setItem(2, 5, QTableWidgetItem(""))
        tableWidget.setItem(2, 6, QTableWidgetItem("3"))
        tableWidget.setItem(2, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(2, 8, QTableWidgetItem("08.10.2010 8:32"))
        tableWidget.setItem(2, 9, QTableWidgetItem("772A0000-566DD000"))
        tableWidget.setItem(2, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        tableWidget.setRowHeight(3, height)
        tableWidget.setVerticalHeaderItem(3, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(3, 0, QTableWidgetItem("QtCoreed4.dll"))
        tableWidget.setItem(3, 1, QTableWidgetItem("C:/Qt/4.6.2/Bin/QtCored4.dll"))
        tableWidget.setItem(3, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(3, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(3, 4, QTableWidgetItem("Symbols loaded."))
        tableWidget.setItem(3, 5, QTableWidgetItem("C:/Qt/4.6.2/lib/QtCored4.pdb"))
        tableWidget.setItem(3, 6, QTableWidgetItem("4"))
        tableWidget.setItem(3, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(3, 8, QTableWidgetItem("08.10.2010 8:32"))
        tableWidget.setItem(3, 9, QTableWidgetItem("772A0000-566DD000"))
        tableWidget.setItem(3, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        tableWidget.setRowHeight(4, height)
        tableWidget.setVerticalHeaderItem(4, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(4, 0, QTableWidgetItem("user32.dll"))
        tableWidget.setItem(4, 1, QTableWidgetItem("C:/Windows/System32/user32.dll"))
        tableWidget.setItem(4, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(4, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(4, 4, QTableWidgetItem("No symbols loaded."))
        tableWidget.setItem(4, 5, QTableWidgetItem(""))
        tableWidget.setItem(4, 6, QTableWidgetItem("3"))
        tableWidget.setItem(4, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(4, 8, QTableWidgetItem("08.10.2010 8:32"))
        tableWidget.setItem(4, 9, QTableWidgetItem("552A0000-544AD000"))
        tableWidget.setItem(4, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        tableWidget.setRowHeight(5, height)
        tableWidget.setVerticalHeaderItem(5, QTableWidgetItem(QIcon(":/res/modules.png"), ""))
        tableWidget.setItem(5, 0, QTableWidgetItem("usp10.dll"))
        tableWidget.setItem(5, 1, QTableWidgetItem("C:/Windows/System32/usp10.dll"))
        tableWidget.setItem(5, 2, QTableWidgetItem("N/A"))
        tableWidget.setItem(5, 3, QTableWidgetItem("N/A"))
        tableWidget.setItem(5, 4, QTableWidgetItem("No symbols loaded."))
        tableWidget.setItem(5, 5, QTableWidgetItem(""))
        tableWidget.setItem(5, 6, QTableWidgetItem("3"))
        tableWidget.setItem(5, 7, QTableWidgetItem("6.1.7600.16385 (win7_rtm.090713-1255)"))
        tableWidget.setItem(5, 8, QTableWidgetItem("08.10.2010 8:32"))
        tableWidget.setItem(5, 9, QTableWidgetItem("552A0000-544AD000"))
        tableWidget.setItem(5, 10, QTableWidgetItem("[3376] customstyles.exe: Native"))

        panel.setWidget(tableWidget)
        return panel

    def createOpenGLPanel(self):
        panel = DockWidgetPanel("OpenGL {0}".format(self.numberOpenGL), self.dockPanelManager())
        self.numberOpenGL = self.numberOpenGL + 1
        glWidget = GLWidget(self.numberOpenGL)
        panel.setWidget(glWidget)
        return panel

    @QtCore.Slot(DockPanelRequestedArgs)
    def panelRequested(self, args):
        panel = None
        id = args.id()
        if "form" in id:
            panel = self.createFormPanel()
        elif "tree" in id:
            panel = self.createTreePanel()
        elif "table" in id:
            panel = self.createTablePanel()
        elif "opengl" in id:
            panel = self.createOpenGLPanel()
        else:
            panel = DockWidgetPanel(self.dockPanelManager()) # Default empty panel.
        if panel != None:
            panel.setId(args.id())
            args.setPanel(panel)
            args.setHandled(True)

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