First Commit

This commit is contained in:
2025-11-18 14:18:26 -07:00
parent 33eb6e3707
commit 27277ec342
6106 changed files with 3571167 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring
from PySide6 import QtWidgets, QtGui, QtCore
# pylint: disable=too-few-public-methods
class MyWidget(QtWidgets.QWidget):
s_images = {}
def __init__(self, backgroundFile="", logoFile="", parent=None):
super().__init__(parent)
self.background = self._lookupImage(backgroundFile)
self.logo = self._lookupImage(logoFile)
# pylint: disable=no-self-use
def _lookupImage(self, imageName):
if imageName == "":
return None
if imageName not in MyWidget.s_images:
MyWidget.s_images[imageName] = QtGui.QImage(imageName)
return MyWidget.s_images[imageName]
def drawLogo(self, p):
if not self.logo:
return
ratio = self.logo.height() / (self.logo.width() * 1.0)
maxWidth = int(0.80 * self.size().width())
maxHeight = int(0.80 * self.size().height())
proposedHeight = int(maxWidth * ratio)
if proposedHeight <= maxHeight:
width = maxWidth
else:
width = int(maxHeight / ratio)
height = int(width * ratio)
targetLogoRect = QtCore.QRect(0, 0, width, height)
targetLogoRect.moveCenter(self.rect().center(
) + QtCore.QPoint(0, -int(self.size().height() * 0.00)))
p.drawImage(targetLogoRect, self.logo, self.logo.rect())

View File

@@ -0,0 +1,11 @@
Running python example
======================
Generate resource file with:
~# rcc -g python -o rc_assets.py ../../examples/dockwidgets/resources_example.qrc
(on some systems, rcc might be invoked as rcc-qt6)
Make sure you installed kddockwidgets and set PYTHONPATH accordingly.
Run the app:
~# python3 main.py

View File

@@ -0,0 +1,86 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
''' KDDockWidgets example (Qt6) '''
import sys
from PySide6 import QtWidgets, QtCore
# pylint: disable=no-name-in-module
from PyKDDockWidgets import KDDockWidgets
from MyWidget import MyWidget
try:
# pylint: disable=unused-import
import rc_assets
except ImportError:
sys.exit(
'''
Oops.. rc_assets needs to be generated first.
Please run:
rcc -g python -o rc_assets.py ../../examples/dockwidgets/resources_example.qrc
(Make sure to use the rcc from the Qt6 version used to generate the bindings!)
On some systems rcc might be invoked as rcc-qt6.
'''
)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
app.setOrganizationName("KDAB")
app.setApplicationName("Test app")
KDDockWidgets.initFrontend(KDDockWidgets.FrontendType.QtWidgets)
app.setStyle(QtWidgets.QStyleFactory.create("Fusion"))
# 1. Create our main window
mainWindow = KDDockWidgets.MainWindow("MyMainWindow")
mainWindow.setWindowTitle("Main Window")
mainWindow.resize(1200, 1200)
mainWindow.show()
# 2. Create a dock widget, it needs a unique name
dock1 = KDDockWidgets.DockWidget("MyDock1")
widget1 = MyWidget("", "")
dock1.setWidget(widget1)
dock2 = KDDockWidgets.DockWidget("MyDock2")
widget2 = MyWidget(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png")
dock2.setWidget(widget2)
dock3 = KDDockWidgets.DockWidget("MyDock3")
widget3 = MyWidget(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png")
dock3.setWidget(widget3)
dock4 = KDDockWidgets.DockWidget("MyDock4")
widget4 = MyWidget(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png")
dock4.setWidget(widget4)
dock5 = KDDockWidgets.DockWidget("MyDock5")
widget5 = MyWidget(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png")
dock5.setWidget(widget5)
# 3. Add them to the main window
mainWindow.addKDockWidget(dock1, KDDockWidgets.Location.Location_OnLeft)
mainWindow.addKDockWidget(dock2, KDDockWidgets.Location.Location_OnTop)
# 4. Add dock3 to the right of dock2
mainWindow.addKDockWidget(dock3, KDDockWidgets.Location.Location_OnRight, dock2)
# 5. dock4 is docked at the bottom, with 200px height
preferredSize = QtCore.QSize(0, 200)
mainWindow.addKDockWidget(dock4, KDDockWidgets.Location.Location_OnBottom, None, preferredSize)
# 5. dock5 will be its own top level (floating window)
dock5.open()
app.exec()