aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/animation/animatedtiles/animatedtiles.py31
-rw-r--r--examples/widgets/animation/animatedtiles/animatedtiles.pyproject3
-rw-r--r--examples/widgets/animation/appchooser/appchooser.py4
-rw-r--r--examples/widgets/animation/appchooser/appchooser.pyproject2
-rw-r--r--examples/widgets/animation/easing/easing.py37
-rw-r--r--examples/widgets/animation/easing/form.ui105
-rw-r--r--examples/widgets/animation/easing/images/qt-logo.pngbin5149 -> 0 bytes
-rw-r--r--examples/widgets/animation/easing/ui_form.py65
-rw-r--r--examples/widgets/animation/states/states.py4
-rw-r--r--examples/widgets/animation/states/states.pyproject2
-rw-r--r--examples/widgets/codeeditor/codeeditor.py104
-rw-r--r--examples/widgets/codeeditor/codeeditor.pyproject3
-rw-r--r--examples/widgets/codeeditor/doc/codeeditor.pngbin7759 -> 0 bytes
-rw-r--r--examples/widgets/codeeditor/doc/codeeditor.rst9
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.py6
-rw-r--r--examples/widgets/desktop/systray/images/bad.png (renamed from examples/widgets/systray/images/bad.png)bin2496 -> 2496 bytes
-rw-r--r--examples/widgets/desktop/systray/images/heart.png (renamed from examples/widgets/systray/images/heart.png)bin25780 -> 25780 bytes
-rw-r--r--examples/widgets/desktop/systray/images/trash.png (renamed from examples/widgets/systray/images/trash.png)bin12128 -> 12128 bytes
-rw-r--r--examples/widgets/desktop/systray/main.py (renamed from examples/widgets/systray/main.py)0
-rw-r--r--examples/widgets/desktop/systray/rc_systray.py (renamed from examples/widgets/systray/rc_systray.py)0
-rw-r--r--examples/widgets/desktop/systray/systray.pyproject (renamed from examples/widgets/systray/systray.pyproject)0
-rw-r--r--examples/widgets/desktop/systray/systray.qrc (renamed from examples/widgets/systray/systray.qrc)0
-rw-r--r--examples/widgets/desktop/systray/window.py (renamed from examples/widgets/systray/window.py)8
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.py20
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.pyproject3
-rw-r--r--examples/widgets/dialogs/classwizard/listchooser.py9
-rw-r--r--examples/widgets/dialogs/findfiles/findfiles.py184
-rw-r--r--examples/widgets/dialogs/findfiles/findfiles.pyproject3
-rw-r--r--examples/widgets/dialogs/standarddialogs/standarddialogs.py142
-rw-r--r--examples/widgets/dialogs/trivialwizard/trivialwizard.py4
-rw-r--r--examples/widgets/draganddrop/draggabletext/draggabletext.py5
-rw-r--r--examples/widgets/draganddrop/draggabletext/draggabletext.pyproject3
-rw-r--r--examples/widgets/draganddrop/dropsite/doc/dropsite.rst8
-rw-r--r--examples/widgets/draganddrop/dropsite/droparea.py67
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsite.pyproject3
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsitewindow.py115
-rw-r--r--examples/widgets/draganddrop/dropsite/main.py (renamed from examples/widgets/codeeditor/main.py)12
-rw-r--r--examples/widgets/effects/lighting/lighting.py5
-rw-r--r--examples/widgets/gettext/doc/gettext.rst7
-rw-r--r--examples/widgets/gettext/main.py4
-rw-r--r--examples/widgets/graphicsview/anchorlayout/anchorlayout.py4
-rw-r--r--examples/widgets/graphicsview/collidingmice/collidingmice.py16
-rw-r--r--examples/widgets/graphicsview/collidingmice/collidingmice.pyproject2
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramscene.py158
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramscene.pyproject2
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py55
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pyproject2
-rw-r--r--examples/widgets/graphicsview/elasticnodes/elasticnodes.py26
-rw-r--r--examples/widgets/imageviewer/imageviewer.py14
-rw-r--r--examples/widgets/itemviews/address_book/adddialogwidget.py4
-rw-r--r--examples/widgets/itemviews/address_book/address_book.py18
-rw-r--r--examples/widgets/itemviews/address_book/addresswidget.py10
-rw-r--r--examples/widgets/itemviews/address_book/tablemodel.py4
-rw-r--r--examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py31
-rw-r--r--examples/widgets/itemviews/dirview/dirview.py59
-rw-r--r--examples/widgets/itemviews/dirview/dirview.pyproject3
-rw-r--r--examples/widgets/itemviews/dirview/doc/dirview.rst5
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.py2
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.py9
-rw-r--r--examples/widgets/itemviews/fetchmore/fetchmore.py7
-rw-r--r--examples/widgets/itemviews/jsonmodel/jsonmodel.py7
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/doc/spinboxdelegate.rst5
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py79
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pyproject3
-rw-r--r--examples/widgets/itemviews/spreadsheet/doc/spreadsheet.pngbin0 -> 40187 bytes
-rw-r--r--examples/widgets/itemviews/spreadsheet/doc/spreadsheet.rst10
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.py19
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.py544
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.py67
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetitem.py122
-rw-r--r--examples/widgets/itemviews/stardelegate/stardelegate.py12
-rw-r--r--examples/widgets/itemviews/stardelegate/stareditor.py3
-rw-r--r--examples/widgets/itemviews/stardelegate/starrating.py6
-rw-r--r--examples/widgets/layouts/basiclayouts/basiclayouts.py8
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py12
-rw-r--r--examples/widgets/linguist/doc/linguist.rst7
-rw-r--r--examples/widgets/linguist/linguist.qrc4
-rw-r--r--examples/widgets/linguist/main.py11
-rw-r--r--examples/widgets/mainwindows/application/application.py89
-rw-r--r--examples/widgets/mainwindows/application/application.pyproject2
-rw-r--r--examples/widgets/mainwindows/dockwidgets/dockwidgets.py76
-rw-r--r--examples/widgets/mainwindows/dockwidgets/dockwidgets.pyproject2
-rw-r--r--examples/widgets/mainwindows/mdi/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/save.pngbin1187 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.py125
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.pyproject2
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.qrc10
-rw-r--r--examples/widgets/mainwindows/mdi/mdi_rc.py608
-rw-r--r--examples/widgets/painting/basicdrawing/basicdrawing.py27
-rw-r--r--examples/widgets/painting/basicdrawing/basicdrawing.pyproject2
-rw-r--r--examples/widgets/painting/concentriccircles/concentriccircles.py9
-rw-r--r--examples/widgets/painting/painter/painter.py23
-rw-r--r--examples/widgets/painting/plot/plot.py5
-rw-r--r--examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst34
-rw-r--r--examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webpbin0 -> 8556 bytes
-rw-r--r--examples/widgets/rhi/simplerhiwidget/examplewidget.py135
-rw-r--r--examples/widgets/rhi/simplerhiwidget/main.py35
-rw-r--r--examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py163
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsbbin0 -> 738 bytes
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsbbin0 -> 1091 bytes
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shaders/color.frag10
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shaders/color.vert16
-rw-r--r--examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject4
-rw-r--r--examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc6
-rw-r--r--examples/widgets/richtext/orderform/orderform.py31
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py4
-rw-r--r--examples/widgets/richtext/textedit/main.py3
-rw-r--r--examples/widgets/richtext/textedit/textedit.py59
-rw-r--r--examples/widgets/richtext/textobject/textobject.py6
-rw-r--r--examples/widgets/state-machine/eventtrans/eventtrans.py57
-rw-r--r--examples/widgets/state-machine/eventtrans/eventtrans.pyproject3
-rw-r--r--examples/widgets/state-machine/factstates/factstates.py89
-rw-r--r--examples/widgets/state-machine/factstates/factstates.pyproject3
-rw-r--r--examples/widgets/state-machine/ping_pong/ping_pong.py70
-rw-r--r--examples/widgets/state-machine/ping_pong/ping_pong.pyproject3
-rw-r--r--examples/widgets/state-machine/rogue/rogue.py179
-rw-r--r--examples/widgets/state-machine/rogue/rogue.pyproject3
-rw-r--r--examples/widgets/state-machine/trafficlight/doc/trafficlight.pngbin79 -> 0 bytes
-rw-r--r--examples/widgets/state-machine/trafficlight/doc/trafficlight.rst10
-rw-r--r--examples/widgets/state-machine/trafficlight/trafficlight.py117
-rw-r--r--examples/widgets/state-machine/trafficlight/trafficlight.pyproject3
-rw-r--r--examples/widgets/state-machine/twowaybutton/twowaybutton.py33
-rw-r--r--examples/widgets/state-machine/twowaybutton/twowaybutton.pyproject3
-rw-r--r--examples/widgets/tools/regularexpression/regularexpression.py2
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.py50
-rw-r--r--examples/widgets/tutorials/addressbook/part1.py5
-rw-r--r--examples/widgets/tutorials/addressbook/part2.py13
-rw-r--r--examples/widgets/tutorials/addressbook/part3.py15
-rw-r--r--examples/widgets/tutorials/addressbook/part4.py32
-rw-r--r--examples/widgets/tutorials/addressbook/part5.py36
-rw-r--r--examples/widgets/tutorials/addressbook/part6.py50
-rw-r--r--examples/widgets/tutorials/addressbook/part7.py57
-rw-r--r--examples/widgets/tutorials/cannon/t10.py8
-rw-r--r--examples/widgets/tutorials/cannon/t11.py8
-rw-r--r--examples/widgets/tutorials/cannon/t12.py8
-rw-r--r--examples/widgets/tutorials/cannon/t13.py10
-rw-r--r--examples/widgets/tutorials/cannon/t14.py17
-rw-r--r--examples/widgets/tutorials/cannon/t2.py3
-rw-r--r--examples/widgets/tutorials/cannon/t4.py2
-rw-r--r--examples/widgets/tutorials/cannon/t5.py2
-rw-r--r--examples/widgets/tutorials/cannon/t6.py2
-rw-r--r--examples/widgets/tutorials/cannon/t7.py2
-rw-r--r--examples/widgets/tutorials/cannon/t8.py8
-rw-r--r--examples/widgets/tutorials/cannon/t9.py8
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly.py38
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting.py65
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel.py53
-rw-r--r--examples/widgets/tutorials/modelview/4_headers.py43
-rw-r--r--examples/widgets/tutorials/modelview/5_edit.py73
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview.py42
-rw-r--r--examples/widgets/tutorials/modelview/7_selections.py71
-rw-r--r--examples/widgets/tutorials/modelview/doc/modelview.rst4
-rw-r--r--examples/widgets/tutorials/modelview/modelview.pyproject9
-rw-r--r--examples/widgets/widgets/charactermap/charactermap.pyproject4
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.py133
-rw-r--r--examples/widgets/widgets/charactermap/doc/charactermap.rst8
-rw-r--r--examples/widgets/widgets/charactermap/fontinfodialog.py47
-rw-r--r--examples/widgets/widgets/charactermap/main.py17
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.py167
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.py41
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.pyproject3
-rw-r--r--examples/widgets/widgets/digitalclock/doc/digitalclock-screenshot.pngbin0 -> 726 bytes
-rw-r--r--examples/widgets/widgets/digitalclock/doc/digitalclock.rst14
-rw-r--r--examples/widgets/widgets/tetrix/doc/tetrix-screenshot.png (renamed from examples/widgets/tetrix/doc/tetrix-screenshot.png)bin5396 -> 5396 bytes
-rw-r--r--examples/widgets/widgets/tetrix/doc/tetrix.rst (renamed from examples/widgets/tetrix/doc/tetrix.rst)0
-rw-r--r--examples/widgets/widgets/tetrix/tetrix.py (renamed from examples/widgets/tetrix/tetrix.py)55
-rw-r--r--examples/widgets/widgets/tetrix/tetrix.pyproject (renamed from examples/widgets/tetrix/tetrix.pyproject)0
-rw-r--r--examples/widgets/widgetsgallery/main.py3
-rw-r--r--examples/widgets/widgetsgallery/widgetgallery.py26
173 files changed, 3341 insertions, 2299 deletions
diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py
index 6ef62c2fd..02fc75bf5 100644
--- a/examples/widgets/animation/animatedtiles/animatedtiles.py
+++ b/examples/widgets/animation/animatedtiles/animatedtiles.py
@@ -8,14 +8,14 @@ import math
from PySide6.QtCore import (QEasingCurve, QObject, QParallelAnimationGroup,
QPointF, QPropertyAnimation, QRandomGenerator,
QRectF, QTimer, Qt, Property, Signal)
-from PySide6.QtGui import (QBrush, QColor, QLinearGradient, QPainter,
+from PySide6.QtGui import (QBrush, QLinearGradient, QPainter,
QPainterPath, QPixmap, QTransform)
from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsPixmapItem,
QGraphicsRectItem, QGraphicsScene, QGraphicsView,
- QGraphicsWidget, QStyle, QWidget)
+ QGraphicsWidget, QStyle)
from PySide6.QtStateMachine import QState, QStateMachine
-import animatedtiles_rc
+import animatedtiles_rc # noqa: F401
# Deriving from more than one wrapped class is not supported, so we use
@@ -95,7 +95,7 @@ class Button(QGraphicsWidget):
painter.drawEllipse(r.adjusted(5, 5, -5, -5))
painter.drawPixmap(-self._pix.width() / 2, -self._pix.height() / 2,
- self._pix)
+ self._pix)
def mousePressEvent(self, ev):
self.pressed.emit()
@@ -123,7 +123,7 @@ if __name__ == '__main__':
for i in range(64):
item = Pixmap(kinetic_pix)
item.pixmap_item.setOffset(-kinetic_pix.width() / 2,
- -kinetic_pix.height() / 2)
+ -kinetic_pix.height() / 2)
item.pixmap_item.setZValue(i)
items.append(item)
scene.addItem(item.pixmap_item)
@@ -161,23 +161,25 @@ if __name__ == '__main__':
for i, item in enumerate(items):
# Ellipse.
ellipse_state.assignProperty(item, 'pos',
- QPointF(math.cos((i / 63.0) * 6.28) * 250,
- math.sin((i / 63.0) * 6.28) * 250))
+ QPointF(math.cos((i / 63.0) * 6.28) * 250,
+ math.sin((i / 63.0) * 6.28) * 250))
# Figure 8.
figure_8state.assignProperty(item, 'pos',
- QPointF(math.sin((i / 63.0) * 6.28) * 250,
- math.sin(((i * 2) / 63.0) * 6.28) * 250))
+ QPointF(math.sin((i / 63.0) * 6.28) * 250,
+ math.sin(((i * 2) / 63.0) * 6.28) * 250))
# Random.
random_state.assignProperty(item, 'pos',
- QPointF(-250 + generator.bounded(0, 500),
- -250 + generator.bounded(0, 500)))
+ QPointF(-250 + generator.bounded(0, 500),
+ -250 + generator.bounded(0, 500)))
# Tiled.
+ width = kinetic_pix.width()
+ height = kinetic_pix.height()
tiled_state.assignProperty(item, 'pos',
- QPointF(((i % 8) - 4) * kinetic_pix.width() + kinetic_pix.width() / 2,
- ((i // 8) - 4) * kinetic_pix.height() + kinetic_pix.height() / 2))
+ QPointF(((i % 8) - 4) * width + width / 2,
+ ((i // 8) - 4) * height + height / 2))
# Centered.
centered_state.assignProperty(item, 'pos', QPointF())
@@ -188,8 +190,7 @@ if __name__ == '__main__':
view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
view.setBackgroundBrush(QBrush(bg_pix))
view.setCacheMode(QGraphicsView.CacheBackground)
- view.setRenderHints(
- QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
+ view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
view.show()
states = QStateMachine()
diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.pyproject b/examples/widgets/animation/animatedtiles/animatedtiles.pyproject
index 08ee55685..20f4abe43 100644
--- a/examples/widgets/animation/animatedtiles/animatedtiles.pyproject
+++ b/examples/widgets/animation/animatedtiles/animatedtiles.pyproject
@@ -1,4 +1,3 @@
{
- "files": ["animatedtiles.qrc", "animatedtiles.py",
- "animatedtiles_rc.py"]
+ "files": ["animatedtiles.qrc", "animatedtiles.py"]
}
diff --git a/examples/widgets/animation/appchooser/appchooser.py b/examples/widgets/animation/appchooser/appchooser.py
index 5421c8c2f..610050210 100644
--- a/examples/widgets/animation/appchooser/appchooser.py
+++ b/examples/widgets/animation/appchooser/appchooser.py
@@ -8,10 +8,10 @@ from PySide6.QtCore import (QPointF, QPropertyAnimation, QRect, QRectF, Qt,
Signal)
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import (QApplication, QGraphicsScene, QGraphicsView,
- QGraphicsWidget, QWidget)
+ QGraphicsWidget)
from PySide6.QtStateMachine import QState, QStateMachine
-import appchooser_rc
+import appchooser_rc # noqa: F401
class Pixmap(QGraphicsWidget):
diff --git a/examples/widgets/animation/appchooser/appchooser.pyproject b/examples/widgets/animation/appchooser/appchooser.pyproject
index 14bc351a1..f4c122bef 100644
--- a/examples/widgets/animation/appchooser/appchooser.pyproject
+++ b/examples/widgets/animation/appchooser/appchooser.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["appchooser_rc.py", "appchooser.py", "appchooser.qrc"]
+ "files": ["appchooser.py", "appchooser.qrc"]
}
diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py
index 58341c0cf..ba5032458 100644
--- a/examples/widgets/animation/easing/easing.py
+++ b/examples/widgets/animation/easing/easing.py
@@ -8,10 +8,10 @@ import sys
from PySide6.QtCore import (Property, QEasingCurve, QObject, QPropertyAnimation,
QPoint, QPointF, QRect, QRectF, QSize, Qt)
from PySide6.QtGui import (QBrush, QColor, QIcon, QLinearGradient, QPainter,
- QPainterPath, QPen, QPixmap)
+ QPainterPath, QPixmap)
from PySide6.QtWidgets import (QApplication, QGraphicsPixmapItem,
- QGraphicsItem, QGraphicsScene, QGraphicsView,
- QListWidget, QListWidgetItem, QWidget)
+ QGraphicsItem, QGraphicsScene,
+ QListWidgetItem, QWidget)
from ui_form import Ui_Form
@@ -110,7 +110,7 @@ class Window(QWidget):
self._anim = Animation(self._item, b'pos')
self._anim.setEasingCurve(QEasingCurve.OutBounce)
- self._ui.easingCurvePicker.setCurrentRow(int(QEasingCurve.OutBounce))
+ self._ui.easingCurvePicker.setCurrentRow(0)
self.start_animation()
@@ -123,15 +123,7 @@ class Window(QWidget):
brush = QBrush(gradient)
- # The original C++ code uses undocumented calls to get the names of the
- # different curve types. We do the Python equivalant (but without
- # cheating)
- curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items()
- if (isinstance(c, QEasingCurve.Type)
- and c != QEasingCurve.Custom
- and c != QEasingCurve.NCurveTypes
- and c != QEasingCurve.TCBSpline)]
- curve_types.sort(key=lambda ct: ct[1])
+ curve_types = [(f"QEasingCurve.{e.name}", e) for e in QEasingCurve.Type if e.value <= 40]
with QPainter(pix) as painter:
@@ -151,14 +143,13 @@ class Window(QWidget):
# Start point.
painter.setBrush(Qt.red)
- start = QPoint(y_axis,
- x_axis - curve_scale * curve.valueForProgress(0))
+ start = QPoint(y_axis, x_axis - curve_scale * curve.valueForProgress(0))
painter.drawRect(start.x() - 1, start.y() - 1, 3, 3)
# End point.
painter.setBrush(Qt.blue)
end = QPoint(y_axis + curve_scale,
- x_axis - curve_scale * curve.valueForProgress(1))
+ x_axis - curve_scale * curve.valueForProgress(1))
painter.drawRect(end.x() - 1, end.y() - 1, 3, 3)
curve_path = QPainterPath()
@@ -166,7 +157,7 @@ class Window(QWidget):
t = 0.0
while t <= 1.0:
to = QPointF(y_axis + curve_scale * t,
- x_axis - curve_scale * curve.valueForProgress(t))
+ x_axis - curve_scale * curve.valueForProgress(t))
curve_path.lineTo(to)
t += 1.0 / curve_scale
@@ -191,15 +182,15 @@ class Window(QWidget):
self._anim.setEasingCurve(curve_type)
self._anim.setCurrentTime(0)
- is_elastic = (curve_type >= QEasingCurve.InElastic
- and curve_type <= QEasingCurve.OutInElastic)
- is_bounce = (curve_type >= QEasingCurve.InBounce
- and curve_type <= QEasingCurve.OutInBounce)
+ is_elastic = (curve_type.value >= QEasingCurve.InElastic.value
+ and curve_type.value <= QEasingCurve.OutInElastic.value)
+ is_bounce = (curve_type.value >= QEasingCurve.InBounce.value
+ and curve_type.value <= QEasingCurve.OutInBounce.value)
self._ui.periodSpinBox.setEnabled(is_elastic)
self._ui.amplitudeSpinBox.setEnabled(is_elastic or is_bounce)
- self._ui.overshootSpinBox.setEnabled(curve_type >= QEasingCurve.InBack
- and curve_type <= QEasingCurve.OutInBack)
+ self._ui.overshootSpinBox.setEnabled(curve_type.value >= QEasingCurve.InBack.value
+ and curve_type.value <= QEasingCurve.OutInBack.value)
def path_changed(self, index):
self._anim.set_path_type(index)
diff --git a/examples/widgets/animation/easing/form.ui b/examples/widgets/animation/easing/form.ui
index 2397b1787..364aebeda 100644
--- a/examples/widgets/animation/easing/form.ui
+++ b/examples/widgets/animation/easing/form.ui
@@ -49,12 +49,27 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
<property name="title">
<string>Path type</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
<widget class="QRadioButton" name="lineRadio">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>40</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
<property name="text">
<string>Line</string>
</property>
@@ -62,17 +77,23 @@
<bool>true</bool>
</property>
<attribute name="buttonGroup">
- <string notr="true">buttonGroup</string>
+ <string>buttonGroup</string>
</attribute>
</widget>
</item>
- <item>
+ <item row="1" column="0">
<widget class="QRadioButton" name="circleRadio">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>40</height>
+ </size>
+ </property>
<property name="text">
<string>Circle</string>
</property>
<attribute name="buttonGroup">
- <string notr="true">buttonGroup</string>
+ <string>buttonGroup</string>
</attribute>
</widget>
</item>
@@ -96,6 +117,18 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
<property name="text">
<string>Period</string>
</property>
@@ -106,6 +139,18 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
@@ -117,18 +162,17 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Amplitude</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="QDoubleSpinBox" name="amplitudeSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
@@ -140,18 +184,30 @@
</property>
</widget>
</item>
- <item row="2" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label_3">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
<property name="text">
<string>Overshoot</string>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="4" column="1">
<widget class="QDoubleSpinBox" name="overshootSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
@@ -163,6 +219,19 @@
</property>
</widget>
</item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Amplitude</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -196,10 +265,6 @@
<resources/>
<connections/>
<buttongroups>
- <buttongroup name="buttonGroup">
- <property name="exclusive">
- <bool>true</bool>
- </property>
- </buttongroup>
+ <buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
diff --git a/examples/widgets/animation/easing/images/qt-logo.png b/examples/widgets/animation/easing/images/qt-logo.png
deleted file mode 100644
index 14ddf2a02..000000000
--- a/examples/widgets/animation/easing/images/qt-logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/animation/easing/ui_form.py b/examples/widgets/animation/easing/ui_form.py
index 07bfa8fb3..2925cbae7 100644
--- a/examples/widgets/animation/easing/ui_form.py
+++ b/examples/widgets/animation/easing/ui_form.py
@@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'form.ui'
##
-## Created by: Qt User Interface Compiler version 6.2.3
+## Created by: Qt User Interface Compiler version 6.7.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
@@ -29,7 +29,7 @@ class Ui_Form(object):
self.gridLayout.setObjectName(u"gridLayout")
self.easingCurvePicker = QListWidget(Form)
self.easingCurvePicker.setObjectName(u"easingCurvePicker")
- sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.easingCurvePicker.sizePolicy().hasHeightForWidth())
@@ -47,30 +47,33 @@ class Ui_Form(object):
self.verticalLayout.setObjectName(u"verticalLayout")
self.groupBox_2 = QGroupBox(Form)
self.groupBox_2.setObjectName(u"groupBox_2")
- self.verticalLayout_2 = QVBoxLayout(self.groupBox_2)
- self.verticalLayout_2.setObjectName(u"verticalLayout_2")
+ self.groupBox_2.setMaximumSize(QSize(16777215, 16777215))
+ self.gridLayout_2 = QGridLayout(self.groupBox_2)
+ self.gridLayout_2.setObjectName(u"gridLayout_2")
self.lineRadio = QRadioButton(self.groupBox_2)
self.buttonGroup = QButtonGroup(Form)
self.buttonGroup.setObjectName(u"buttonGroup")
- self.buttonGroup.setExclusive(True)
self.buttonGroup.addButton(self.lineRadio)
self.lineRadio.setObjectName(u"lineRadio")
+ self.lineRadio.setMaximumSize(QSize(16777215, 40))
+ self.lineRadio.setLayoutDirection(Qt.LeftToRight)
self.lineRadio.setChecked(True)
- self.verticalLayout_2.addWidget(self.lineRadio)
+ self.gridLayout_2.addWidget(self.lineRadio, 0, 0, 1, 1)
self.circleRadio = QRadioButton(self.groupBox_2)
self.buttonGroup.addButton(self.circleRadio)
self.circleRadio.setObjectName(u"circleRadio")
+ self.circleRadio.setMaximumSize(QSize(16777215, 40))
- self.verticalLayout_2.addWidget(self.circleRadio)
+ self.gridLayout_2.addWidget(self.circleRadio, 1, 0, 1, 1)
self.verticalLayout.addWidget(self.groupBox_2)
self.groupBox = QGroupBox(Form)
self.groupBox.setObjectName(u"groupBox")
- sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
+ sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
@@ -80,50 +83,66 @@ class Ui_Form(object):
self.formLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
self.label = QLabel(self.groupBox)
self.label.setObjectName(u"label")
+ sizePolicy2 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
+ sizePolicy2.setHorizontalStretch(0)
+ sizePolicy2.setVerticalStretch(0)
+ sizePolicy2.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
+ self.label.setSizePolicy(sizePolicy2)
+ self.label.setMinimumSize(QSize(0, 30))
self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label)
self.periodSpinBox = QDoubleSpinBox(self.groupBox)
self.periodSpinBox.setObjectName(u"periodSpinBox")
self.periodSpinBox.setEnabled(False)
+ sizePolicy3 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
+ sizePolicy3.setHorizontalStretch(0)
+ sizePolicy3.setVerticalStretch(0)
+ sizePolicy3.setHeightForWidth(self.periodSpinBox.sizePolicy().hasHeightForWidth())
+ self.periodSpinBox.setSizePolicy(sizePolicy3)
+ self.periodSpinBox.setMinimumSize(QSize(0, 30))
self.periodSpinBox.setMinimum(-1.000000000000000)
self.periodSpinBox.setSingleStep(0.100000000000000)
self.periodSpinBox.setValue(-1.000000000000000)
self.formLayout.setWidget(0, QFormLayout.FieldRole, self.periodSpinBox)
- self.label_2 = QLabel(self.groupBox)
- self.label_2.setObjectName(u"label_2")
-
- self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label_2)
-
self.amplitudeSpinBox = QDoubleSpinBox(self.groupBox)
self.amplitudeSpinBox.setObjectName(u"amplitudeSpinBox")
self.amplitudeSpinBox.setEnabled(False)
+ self.amplitudeSpinBox.setMinimumSize(QSize(0, 30))
self.amplitudeSpinBox.setMinimum(-1.000000000000000)
self.amplitudeSpinBox.setSingleStep(0.100000000000000)
self.amplitudeSpinBox.setValue(-1.000000000000000)
- self.formLayout.setWidget(1, QFormLayout.FieldRole, self.amplitudeSpinBox)
+ self.formLayout.setWidget(2, QFormLayout.FieldRole, self.amplitudeSpinBox)
self.label_3 = QLabel(self.groupBox)
self.label_3.setObjectName(u"label_3")
+ self.label_3.setMinimumSize(QSize(0, 30))
- self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_3)
+ self.formLayout.setWidget(4, QFormLayout.LabelRole, self.label_3)
self.overshootSpinBox = QDoubleSpinBox(self.groupBox)
self.overshootSpinBox.setObjectName(u"overshootSpinBox")
self.overshootSpinBox.setEnabled(False)
+ self.overshootSpinBox.setMinimumSize(QSize(0, 30))
self.overshootSpinBox.setMinimum(-1.000000000000000)
self.overshootSpinBox.setSingleStep(0.100000000000000)
self.overshootSpinBox.setValue(-1.000000000000000)
- self.formLayout.setWidget(2, QFormLayout.FieldRole, self.overshootSpinBox)
+ self.formLayout.setWidget(4, QFormLayout.FieldRole, self.overshootSpinBox)
+
+ self.label_2 = QLabel(self.groupBox)
+ self.label_2.setObjectName(u"label_2")
+ self.label_2.setMinimumSize(QSize(0, 30))
+
+ self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_2)
self.verticalLayout.addWidget(self.groupBox)
- self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
+ self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
self.verticalLayout.addItem(self.verticalSpacer)
@@ -132,11 +151,11 @@ class Ui_Form(object):
self.graphicsView = QGraphicsView(Form)
self.graphicsView.setObjectName(u"graphicsView")
- sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
- sizePolicy2.setHorizontalStretch(0)
- sizePolicy2.setVerticalStretch(0)
- sizePolicy2.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth())
- self.graphicsView.setSizePolicy(sizePolicy2)
+ sizePolicy4 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
+ sizePolicy4.setHorizontalStretch(0)
+ sizePolicy4.setVerticalStretch(0)
+ sizePolicy4.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth())
+ self.graphicsView.setSizePolicy(sizePolicy4)
self.gridLayout.addWidget(self.graphicsView, 1, 1, 1, 1)
@@ -153,7 +172,7 @@ class Ui_Form(object):
self.circleRadio.setText(QCoreApplication.translate("Form", u"Circle", None))
self.groupBox.setTitle(QCoreApplication.translate("Form", u"Properties", None))
self.label.setText(QCoreApplication.translate("Form", u"Period", None))
- self.label_2.setText(QCoreApplication.translate("Form", u"Amplitude", None))
self.label_3.setText(QCoreApplication.translate("Form", u"Overshoot", None))
+ self.label_2.setText(QCoreApplication.translate("Form", u"Amplitude", None))
# retranslateUi
diff --git a/examples/widgets/animation/states/states.py b/examples/widgets/animation/states/states.py
index fa37c7b09..509c3a7aa 100644
--- a/examples/widgets/animation/states/states.py
+++ b/examples/widgets/animation/states/states.py
@@ -12,11 +12,11 @@ from PySide6.QtWidgets import (QApplication, QGraphicsLinearLayout,
QGraphicsObject, QGraphicsProxyWidget,
QGraphicsWidget, QGraphicsScene, QGraphicsView,
QGroupBox, QPushButton, QRadioButton,
- QTextEdit, QVBoxLayout, QWidget)
+ QTextEdit, QVBoxLayout)
from PySide6.QtStateMachine import QState, QStateMachine
-import states_rc
+import states_rc # noqa: F401
class Pixmap(QGraphicsObject):
diff --git a/examples/widgets/animation/states/states.pyproject b/examples/widgets/animation/states/states.pyproject
index d94cf2e65..45ad44e97 100644
--- a/examples/widgets/animation/states/states.pyproject
+++ b/examples/widgets/animation/states/states.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["states.py", "states_rc.py"]
+ "files": ["states.py"]
}
diff --git a/examples/widgets/codeeditor/codeeditor.py b/examples/widgets/codeeditor/codeeditor.py
deleted file mode 100644
index 635dcb7a8..000000000
--- a/examples/widgets/codeeditor/codeeditor.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-from PySide6.QtCore import Slot, Qt, QRect, QSize
-from PySide6.QtGui import QColor, QPainter, QTextFormat
-from PySide6.QtWidgets import QPlainTextEdit, QWidget, QTextEdit
-
-
-class LineNumberArea(QWidget):
- def __init__(self, editor):
- QWidget.__init__(self, editor)
- self._code_editor = editor
-
- def sizeHint(self):
- return QSize(self._code_editor.line_number_area_width(), 0)
-
- def paintEvent(self, event):
- self._code_editor.lineNumberAreaPaintEvent(event)
-
-
-class CodeEditor(QPlainTextEdit):
- def __init__(self):
- super().__init__()
- self.line_number_area = LineNumberArea(self)
-
- self.blockCountChanged[int].connect(self.update_line_number_area_width)
- self.updateRequest[QRect, int].connect(self.update_line_number_area)
- self.cursorPositionChanged.connect(self.highlight_current_line)
-
- self.update_line_number_area_width(0)
- self.highlight_current_line()
-
- def line_number_area_width(self):
- digits = 1
- max_num = max(1, self.blockCount())
- while max_num >= 10:
- max_num *= 0.1
- digits += 1
-
- space = 3 + self.fontMetrics().horizontalAdvance('9') * digits
- return space
-
- def resizeEvent(self, e):
- super().resizeEvent(e)
- cr = self.contentsRect()
- width = self.line_number_area_width()
- rect = QRect(cr.left(), cr.top(), width, cr.height())
- self.line_number_area.setGeometry(rect)
-
- def lineNumberAreaPaintEvent(self, event):
- with QPainter(self.line_number_area) as painter:
- painter.fillRect(event.rect(), Qt.lightGray)
- block = self.firstVisibleBlock()
- block_number = block.blockNumber()
- offset = self.contentOffset()
- top = self.blockBoundingGeometry(block).translated(offset).top()
- bottom = top + self.blockBoundingRect(block).height()
-
- while block.isValid() and top <= event.rect().bottom():
- if block.isVisible() and bottom >= event.rect().top():
- number = str(block_number + 1)
- painter.setPen(Qt.black)
- width = self.line_number_area.width()
- height = self.fontMetrics().height()
- painter.drawText(0, top, width, height, Qt.AlignRight, number)
-
- block = block.next()
- top = bottom
- bottom = top + self.blockBoundingRect(block).height()
- block_number += 1
-
- @Slot()
- def update_line_number_area_width(self, newBlockCount):
- self.setViewportMargins(self.line_number_area_width(), 0, 0, 0)
-
- @Slot()
- def update_line_number_area(self, rect, dy):
- if dy:
- self.line_number_area.scroll(0, dy)
- else:
- width = self.line_number_area.width()
- self.line_number_area.update(0, rect.y(), width, rect.height())
-
- if rect.contains(self.viewport().rect()):
- self.update_line_number_area_width(0)
-
- @Slot()
- def highlight_current_line(self):
- extra_selections = []
-
- if not self.isReadOnly():
- selection = QTextEdit.ExtraSelection()
-
- line_color = QColor(Qt.yellow).lighter(160)
- selection.format.setBackground(line_color)
-
- selection.format.setProperty(QTextFormat.FullWidthSelection, True)
-
- selection.cursor = self.textCursor()
- selection.cursor.clearSelection()
-
- extra_selections.append(selection)
-
- self.setExtraSelections(extra_selections)
diff --git a/examples/widgets/codeeditor/codeeditor.pyproject b/examples/widgets/codeeditor/codeeditor.pyproject
deleted file mode 100644
index f51cfc6d2..000000000
--- a/examples/widgets/codeeditor/codeeditor.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["codeeditor.py", "main.py"]
-}
diff --git a/examples/widgets/codeeditor/doc/codeeditor.png b/examples/widgets/codeeditor/doc/codeeditor.png
deleted file mode 100644
index e3def6b04..000000000
--- a/examples/widgets/codeeditor/doc/codeeditor.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/codeeditor/doc/codeeditor.rst b/examples/widgets/codeeditor/doc/codeeditor.rst
deleted file mode 100644
index 16345eaa3..000000000
--- a/examples/widgets/codeeditor/doc/codeeditor.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-Code Editor Example
-===================
-
-The Code Editor example shows how to create a simple editor that has line
-numbers and that highlights the current line.
-
-.. image:: painter.png
- :width: 400
- :alt: Code Editor Screenshot
diff --git a/examples/widgets/desktop/screenshot/screenshot.py b/examples/widgets/desktop/screenshot/screenshot.py
index c818984dd..a5688da7a 100644
--- a/examples/widgets/desktop/screenshot/screenshot.py
+++ b/examples/widgets/desktop/screenshot/screenshot.py
@@ -5,7 +5,8 @@
import sys
-from PySide6.QtCore import QDir, QPoint, QRect, QStandardPaths, Qt, QTimer
+from PySide6.QtCore import (QDir, QPoint, QRect, QStandardPaths, Qt, QTimer,
+ Slot)
from PySide6.QtGui import QGuiApplication, QImageWriter
from PySide6.QtWidgets import (QApplication, QCheckBox, QDialog, QFileDialog,
QGridLayout, QGroupBox, QHBoxLayout, QLabel,
@@ -72,6 +73,7 @@ class Screenshot(QWidget):
if scaled_size != self.screenshot_label.pixmap().size():
self.update_screenshot_label()
+ @Slot()
def new_screenshot(self):
if self.hide_this_window_checkbox.isChecked():
self.hide()
@@ -79,6 +81,7 @@ class Screenshot(QWidget):
QTimer.singleShot(self.delay_spinbox.value() * 1000, self.shoot_screen)
+ @Slot()
def save_screenshot(self):
fmt = "png" # In order to avoid shadowing built-in format
initial_path = QStandardPaths.writableLocation(QStandardPaths.PicturesLocation)
@@ -127,6 +130,7 @@ class Screenshot(QWidget):
if self.hide_this_window_checkbox.isChecked():
self.show()
+ @Slot()
def update_checkbox(self):
if self.delay_spinbox.value() == 0:
self.hide_this_window_checkbox.setDisabled(True)
diff --git a/examples/widgets/systray/images/bad.png b/examples/widgets/desktop/systray/images/bad.png
index c8701a241..c8701a241 100644
--- a/examples/widgets/systray/images/bad.png
+++ b/examples/widgets/desktop/systray/images/bad.png
Binary files differ
diff --git a/examples/widgets/systray/images/heart.png b/examples/widgets/desktop/systray/images/heart.png
index cee1302b7..cee1302b7 100644
--- a/examples/widgets/systray/images/heart.png
+++ b/examples/widgets/desktop/systray/images/heart.png
Binary files differ
diff --git a/examples/widgets/systray/images/trash.png b/examples/widgets/desktop/systray/images/trash.png
index 4c24db926..4c24db926 100644
--- a/examples/widgets/systray/images/trash.png
+++ b/examples/widgets/desktop/systray/images/trash.png
Binary files differ
diff --git a/examples/widgets/systray/main.py b/examples/widgets/desktop/systray/main.py
index c52c51387..c52c51387 100644
--- a/examples/widgets/systray/main.py
+++ b/examples/widgets/desktop/systray/main.py
diff --git a/examples/widgets/systray/rc_systray.py b/examples/widgets/desktop/systray/rc_systray.py
index 9a6dec317..9a6dec317 100644
--- a/examples/widgets/systray/rc_systray.py
+++ b/examples/widgets/desktop/systray/rc_systray.py
diff --git a/examples/widgets/systray/systray.pyproject b/examples/widgets/desktop/systray/systray.pyproject
index eadfb0d7a..eadfb0d7a 100644
--- a/examples/widgets/systray/systray.pyproject
+++ b/examples/widgets/desktop/systray/systray.pyproject
diff --git a/examples/widgets/systray/systray.qrc b/examples/widgets/desktop/systray/systray.qrc
index a8b653584..a8b653584 100644
--- a/examples/widgets/systray/systray.qrc
+++ b/examples/widgets/desktop/systray/systray.qrc
diff --git a/examples/widgets/systray/window.py b/examples/widgets/desktop/systray/window.py
index c04a33e3a..0b5bc39dc 100644
--- a/examples/widgets/systray/window.py
+++ b/examples/widgets/desktop/systray/window.py
@@ -9,7 +9,7 @@ from PySide6.QtWidgets import (QCheckBox, QComboBox, QDialog,
QSpinBox, QStyle, QSystemTrayIcon, QTextEdit,
QVBoxLayout)
-import rc_systray
+import rc_systray # noqa: F401
class Window(QDialog):
@@ -190,8 +190,8 @@ class Window(QDialog):
self._body_label = QLabel("Body:")
self._body_edit = QTextEdit()
- self._body_edit.setPlainText("Don't believe me. Honestly, I don't have a clue."
- "\nClick this balloon for details.")
+ self._body_edit.setPlainText("Don't believe me. Honestly, I don't have a clue.\n"
+ "Click this balloon for details.")
self._show_message_button = QPushButton("Show Message")
self._show_message_button.setDefault(True)
@@ -222,7 +222,7 @@ class Window(QDialog):
self._restore_action.triggered.connect(self.showNormal)
self._quit_action = QAction("Quit", self)
- self._quit_action.triggered.connect(qApp.quit)
+ self._quit_action.triggered.connect(qApp.quit) # noqa: F821
def create_tray_icon(self):
self._tray_icon_menu = QMenu(self)
diff --git a/examples/widgets/dialogs/classwizard/classwizard.py b/examples/widgets/dialogs/classwizard/classwizard.py
index d76eaa754..0efbde69f 100644
--- a/examples/widgets/dialogs/classwizard/classwizard.py
+++ b/examples/widgets/dialogs/classwizard/classwizard.py
@@ -6,18 +6,16 @@ import os
from pathlib import Path
import sys
-from PySide6.QtCore import (QByteArray, QDir, QFile, QFileInfo,
- QRegularExpression, Qt, QUrl, Slot)
+from PySide6.QtCore import QDir, QFileInfo, QUrl, Slot
from PySide6.QtGui import QDesktopServices, QPixmap
from PySide6.QtWidgets import (QApplication, QComboBox, QCheckBox, QFormLayout,
- QFileDialog, QGroupBox, QGridLayout,
- QHBoxLayout, QLabel, QLineEdit, QMessageBox,
- QPushButton, QRadioButton, QToolButton,
- QVBoxLayout, QWizard, QWizardPage)
+ QFileDialog, QHBoxLayout, QLabel, QLineEdit,
+ QMessageBox, QToolButton, QVBoxLayout, QWizard,
+ QWizardPage)
-from listchooser import ListChooser, PropertyChooser, SignalChooser
+from listchooser import PropertyChooser, SignalChooser
-import classwizard_rc
+import classwizard_rc # noqa: F401
BASE_CLASSES = ['<None>', 'PySide6.QtCore.QObject',
@@ -77,7 +75,7 @@ class ClassWizard(QWizard):
"""Overrides QWizard.nextId() to insert the property/signal
page in case the class is a QObject."""
idx = self.currentId()
- if self.currentId() == self._class_info_index:
+ if idx == self._class_info_index:
qobject = self.field('qobject')
return self._qobject_index if qobject else self._output_index
return super(ClassWizard, self).nextId()
@@ -177,7 +175,7 @@ class ClassWizard(QWizard):
block += '):\n'
if base_class:
- block += f' super().__init__('
+ block += ' super().__init__('
if qobject:
block += 'parent'
block += ')\n'
@@ -335,7 +333,7 @@ class OutputFilesPage(QWizardPage):
def _choose_output_dir(self):
directory = QFileDialog.getExistingDirectory(self, "Output Directory",
- self.output_dir())
+ self.output_dir())
if directory:
self.set_output_dir(directory)
diff --git a/examples/widgets/dialogs/classwizard/classwizard.pyproject b/examples/widgets/dialogs/classwizard/classwizard.pyproject
index 6086099b8..fcc96ef28 100644
--- a/examples/widgets/dialogs/classwizard/classwizard.pyproject
+++ b/examples/widgets/dialogs/classwizard/classwizard.pyproject
@@ -1,4 +1,3 @@
{
- "files": ["classwizard.qrc", "classwizard.py", "classwizard_rc.py",
- "listchooser.py", "classwizard_rc.pyc"]
+ "files": ["classwizard.qrc", "classwizard.py", "listchooser.py"]
}
diff --git a/examples/widgets/dialogs/classwizard/listchooser.py b/examples/widgets/dialogs/classwizard/listchooser.py
index a51c963c4..6bf47c6d1 100644
--- a/examples/widgets/dialogs/classwizard/listchooser.py
+++ b/examples/widgets/dialogs/classwizard/listchooser.py
@@ -1,14 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-from PySide6.QtCore import (QCoreApplication, QDir, QRegularExpression, Qt,
- Property, Slot)
+from PySide6.QtCore import QRegularExpression, Property, Slot
from PySide6.QtGui import QRegularExpressionValidator
from PySide6.QtWidgets import (QComboBox, QDialog, QDialogButtonBox,
QFormLayout, QGroupBox, QHBoxLayout,
- QInputDialog, QLineEdit, QListWidget,
+ QLineEdit, QListWidget,
QListWidgetItem, QPushButton, QVBoxLayout,
- QWidget)
+ )
DEFAULT_TYPES = ['int', 'str', 'PySide6.QtCore.QPoint', 'PySide6.QtCore.QRect',
@@ -28,7 +27,7 @@ class ValidatingInputDialog(QDialog):
self._lineedit = QLineEdit()
self._lineedit.setClearButtonEnabled(True)
re = QRegularExpression(pattern)
- assert(re.isValid())
+ assert re.isValid()
self._validator = QRegularExpressionValidator(re, self)
self._lineedit.setValidator(self._validator)
self._form_layout.addRow(label, self._lineedit)
diff --git a/examples/widgets/dialogs/findfiles/findfiles.py b/examples/widgets/dialogs/findfiles/findfiles.py
deleted file mode 100644
index 188888eee..000000000
--- a/examples/widgets/dialogs/findfiles/findfiles.py
+++ /dev/null
@@ -1,184 +0,0 @@
-# Copyright (C) 2013 Riverbank Computing Limited.
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-"""PySide6 port of the widgets/dialogs/findfiles example from Qt v5.x"""
-
-import sys
-
-from PySide6.QtCore import (QCoreApplication, QDir, QFile, QFileInfo,
- QIODevice, QTextStream, QUrl, Qt)
-from PySide6.QtGui import QDesktopServices
-from PySide6.QtWidgets import (QAbstractItemView, QApplication, QComboBox,
- QDialog, QFileDialog, QGridLayout, QHBoxLayout,
- QHeaderView, QLabel, QLineEdit, QProgressDialog,
- QPushButton, QSizePolicy, QTableWidget,
- QTableWidgetItem, QVBoxLayout, QWidget)
-
-
-class Window(QDialog):
- def __init__(self, parent=None):
- super().__init__(parent)
-
- self._browse_button = self.create_button("&Browse...", self.browse)
- self._find_button = self.create_button("&Find", self.find)
-
- self._file_combo_box = self.create_combo_box("*")
- self._text_combo_box = self.create_combo_box()
- self._directory_combo_box = self.create_combo_box(QDir.currentPath())
-
- file_label = QLabel("Named:")
- text_label = QLabel("Containing text:")
- directory_label = QLabel("In directory:")
- self._files_found_label = QLabel()
-
- self.create_files_table()
-
- buttons_layout = QHBoxLayout()
- buttons_layout.addStretch()
- buttons_layout.addWidget(self._find_button)
-
- main_layout = QGridLayout()
- main_layout.addWidget(file_label, 0, 0)
- main_layout.addWidget(self._file_combo_box, 0, 1, 1, 2)
- main_layout.addWidget(text_label, 1, 0)
- main_layout.addWidget(self._text_combo_box, 1, 1, 1, 2)
- main_layout.addWidget(directory_label, 2, 0)
- main_layout.addWidget(self._directory_combo_box, 2, 1)
- main_layout.addWidget(self._browse_button, 2, 2)
- main_layout.addWidget(self._files_table, 3, 0, 1, 3)
- main_layout.addWidget(self._files_found_label, 4, 0)
- main_layout.addLayout(buttons_layout, 5, 0, 1, 3)
- self.setLayout(main_layout)
-
- self.setWindowTitle("Find Files")
- self.resize(500, 300)
-
- def browse(self):
- directory = QFileDialog.getExistingDirectory(self, "Find Files",
- QDir.currentPath())
-
- if directory:
- if self._directory_combo_box.findText(directory) == -1:
- self._directory_combo_box.addItem(directory)
-
- self._directory_combo_box.setCurrentIndex(self._directory_combo_box.findText(directory))
-
- @staticmethod
- def update_combo_box(comboBox):
- if comboBox.findText(comboBox.currentText()) == -1:
- comboBox.addItem(comboBox.currentText())
-
- def find(self):
- self._files_table.setRowCount(0)
-
- file_name = self._file_combo_box.currentText()
- text = self._text_combo_box.currentText()
- path = self._directory_combo_box.currentText()
-
- self.update_combo_box(self._file_combo_box)
- self.update_combo_box(self._text_combo_box)
- self.update_combo_box(self._directory_combo_box)
-
- self._current_dir = QDir(path)
- if not file_name:
- file_name = "*"
- files = self._current_dir.entryList([file_name],
- QDir.Files | QDir.NoSymLinks)
-
- if text:
- files = self.find_files(files, text)
- self.show_files(files)
-
- def find_files(self, files, text):
- progress_dialog = QProgressDialog(self)
-
- progress_dialog.setCancelButtonText("&Cancel")
- progress_dialog.setRange(0, len(files))
- progress_dialog.setWindowTitle("Find Files")
-
- found_files = []
-
- for i in range(len(files)):
- progress_dialog.setValue(i)
- n = len(files)
- progress_dialog.setLabelText(f"Searching file number {i} of {n}...")
- QCoreApplication.processEvents()
-
- if progress_dialog.wasCanceled():
- break
-
- in_file = QFile(self._current_dir.absoluteFilePath(files[i]))
-
- if in_file.open(QIODevice.ReadOnly):
- stream = QTextStream(in_file)
- while not stream.atEnd():
- if progress_dialog.wasCanceled():
- break
- line = stream.readLine()
- if text in line:
- found_files.append(files[i])
- break
-
- progress_dialog.close()
-
- return found_files
-
- def show_files(self, files):
- for fn in files:
- file = QFile(self._current_dir.absoluteFilePath(fn))
- size = QFileInfo(file).size()
-
- file_name_item = QTableWidgetItem(fn)
- file_name_item.setFlags(file_name_item.flags() ^ Qt.ItemIsEditable)
- size_kb = int((size + 1023) / 1024)
- size_item = QTableWidgetItem(f"{size_kb} KB")
- size_item.setTextAlignment(Qt.AlignVCenter | Qt.AlignRight)
- size_item.setFlags(size_item.flags() ^ Qt.ItemIsEditable)
-
- row = self._files_table.rowCount()
- self._files_table.insertRow(row)
- self._files_table.setItem(row, 0, file_name_item)
- self._files_table.setItem(row, 1, size_item)
-
- n = len(files)
- self._files_found_label.setText(f"{n} file(s) found (Double click on a file to open it)")
-
- def create_button(self, text, member):
- button = QPushButton(text)
- button.clicked.connect(member)
- return button
-
- def create_combo_box(self, text=""):
- combo_box = QComboBox()
- combo_box.setEditable(True)
- combo_box.addItem(text)
- combo_box.setSizePolicy(QSizePolicy.Expanding,
- QSizePolicy.Preferred)
- return combo_box
-
- def create_files_table(self):
- self._files_table = QTableWidget(0, 2)
- self._files_table.setSelectionBehavior(QAbstractItemView.SelectRows)
-
- self._files_table.setHorizontalHeaderLabels(("File Name", "Size"))
- self._files_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
- self._files_table.verticalHeader().hide()
- self._files_table.setShowGrid(False)
-
- self._files_table.cellActivated.connect(self.open_file_of_item)
-
- def open_file_of_item(self, row, column):
- item = self._files_table.item(row, 0)
-
- QDesktopServices.openUrl(QUrl(self._current_dir.absoluteFilePath(item.text())))
-
-
-if __name__ == '__main__':
-
- import sys
-
- app = QApplication(sys.argv)
- window = Window()
- window.show()
- sys.exit(app.exec())
diff --git a/examples/widgets/dialogs/findfiles/findfiles.pyproject b/examples/widgets/dialogs/findfiles/findfiles.pyproject
deleted file mode 100644
index c2fae6dff..000000000
--- a/examples/widgets/dialogs/findfiles/findfiles.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["findfiles.py"]
-}
diff --git a/examples/widgets/dialogs/standarddialogs/standarddialogs.py b/examples/widgets/dialogs/standarddialogs/standarddialogs.py
index 22f4b9eb6..ef677d5a8 100644
--- a/examples/widgets/dialogs/standarddialogs/standarddialogs.py
+++ b/examples/widgets/dialogs/standarddialogs/standarddialogs.py
@@ -5,8 +5,10 @@
"""PySide6 port of the widgets/dialogs/standarddialogs example from Qt v5.x"""
import sys
-from PySide6.QtCore import QDir, QRect, Qt
-from PySide6.QtGui import QFont, QPalette, QScreen
+from textwrap import dedent
+
+from PySide6.QtCore import QDir, Qt, Slot
+from PySide6.QtGui import QFont, QPalette
from PySide6.QtWidgets import (QApplication, QColorDialog, QCheckBox, QDialog,
QErrorMessage, QFontDialog, QFileDialog, QFrame,
QGridLayout, QGroupBox, QInputDialog, QLabel,
@@ -37,10 +39,6 @@ class DialogOptionsWidget(QGroupBox):
class Dialog(QDialog):
- MESSAGE = ("<p>Message boxes have a caption, a text, and up to three "
- "buttons, each with standard or custom texts.</p>"
- "<p>Click a button to close the message box. Pressing the Esc "
- "button will activate the detected escape button (if any).</p>")
def __init__(self, parent=None):
super().__init__(parent)
@@ -143,8 +141,6 @@ class Dialog(QDialog):
self._warning_label.setFrameStyle(frame_style)
self._warning_button = QPushButton("QMessageBox.&warning()")
- self._error_label = QLabel()
- self._error_label.setFrameStyle(frame_style)
self._error_button = QPushButton("QErrorMessage.showM&essage()")
self._integer_button.clicked.connect(self.set_integer)
@@ -230,46 +226,49 @@ class Dialog(QDialog):
layout.addWidget(self._warning_button, 3, 0)
layout.addWidget(self._warning_label, 3, 1)
layout.addWidget(self._error_button, 4, 0)
- layout.addWidget(self._error_label, 4, 1)
spacer = QSpacerItem(0, 0, QSizePolicy.Ignored, QSizePolicy.MinimumExpanding)
layout.addItem(spacer, 5, 0)
toolbox.addItem(page, "Message Boxes")
self.setWindowTitle("Standard Dialogs")
+ @Slot()
def set_integer(self):
i, ok = QInputDialog.getInt(self,
- "QInputDialog.getInteger()", "Percentage:", 25, 0, 100, 1)
+ "QInputDialog.getInteger()", "Percentage:", 25, 0, 100, 1)
if ok:
self._integer_label.setText(f"{i}%")
+ @Slot()
def set_double(self):
d, ok = QInputDialog.getDouble(self, "QInputDialog.getDouble()",
- "Amount:", 37.56, -10000, 10000, 2)
+ "Amount:", 37.56, -10000, 10000, 2)
if ok:
self._double_label.setText(f"${d:g}")
+ @Slot()
def set_item(self):
items = ("Spring", "Summer", "Fall", "Winter")
- item, ok = QInputDialog.getItem(self, "QInputDialog.getItem()",
- "Season:", items, 0, False)
+ item, ok = QInputDialog.getItem(self, "QInputDialog.getItem()", "Season:", items, 0, False)
if ok and item:
self._item_label.setText(item)
+ @Slot()
def set_text(self):
text, ok = QInputDialog.getText(self, "QInputDialog.getText()",
- "User name:", QLineEdit.Normal,
- QDir.home().dirName())
+ "User name:", QLineEdit.Normal, QDir.home().dirName())
if ok and text != '':
self._text_label.setText(text)
+ @Slot()
def set_multiline_text(self):
text, ok = QInputDialog.getMultiLineText(self, "QInputDialog::getMultiLineText()",
- "Address:", "John Doe\nFreedom Street")
+ "Address:", "John Doe\nFreedom Street")
if ok and text != '':
self._multiline_text_label.setText(text)
+ @Slot()
def set_color(self):
options_value = self._color_options.value()
options = QColorDialog.ColorDialogOptions(options_value)
@@ -280,6 +279,7 @@ class Dialog(QDialog):
self._color_label.setPalette(QPalette(color))
self._color_label.setAutoFillBackground(True)
+ @Slot()
def set_font(self):
options_value = self._font_options.value()
options = QFontDialog.FontDialogOptions(options_value)
@@ -294,54 +294,63 @@ class Dialog(QDialog):
self._font_label.setText(font.key())
self._font_label.setFont(font)
+ @Slot()
def set_existing_directory(self):
options_value = self._file_options.value()
options = QFileDialog.Options(options_value) | QFileDialog.ShowDirsOnly
- directory = QFileDialog.getExistingDirectory(self,
- "QFileDialog.getExistingDirectory()",
- self._directory_label.text(), options)
+ directory = QFileDialog.getExistingDirectory(self, "QFileDialog.getExistingDirectory()",
+ self._directory_label.text(), options)
if directory:
self._directory_label.setText(directory)
+ @Slot()
def set_open_file_name(self):
options_value = self._file_options.value()
options = QFileDialog.Options(options_value)
- fileName, filtr = QFileDialog.getOpenFileName(self,
- "QFileDialog.getOpenFileName()",
- self._open_file_name_label.text(),
- "All Files (*);;Text Files (*.txt)", "", options)
+ fileName, _ = QFileDialog.getOpenFileName(self, "QFileDialog.getOpenFileName()",
+ self._open_file_name_label.text(),
+ "All Files (*);;Text Files (*.txt)", "", options)
if fileName:
self._open_file_name_label.setText(fileName)
+ @Slot()
def set_open_file_names(self):
options_value = self._file_options.value()
options = QFileDialog.Options(options_value)
- files, filtr = QFileDialog.getOpenFileNames(self,
- "QFileDialog.getOpenFileNames()", self._open_files_path,
- "All Files (*);;Text Files (*.txt)", "", options)
+ files, _ = QFileDialog.getOpenFileNames(self, "QFileDialog.getOpenFileNames()",
+ self._open_files_path,
+ "All Files (*);;Text Files (*.txt)", "", options)
if files:
self._open_files_path = files[0]
file_list = ', '.join(files)
self._open_file_names_label.setText(f"[{file_list}]")
+ @Slot()
def set_save_file_name(self):
options_value = self._file_options.value()
options = QFileDialog.Options(options_value)
- fileName, filtr = QFileDialog.getSaveFileName(self,
- "QFileDialog.getSaveFileName()",
- self._save_file_name_label.text(),
- "All Files (*);;Text Files (*.txt)", "", options)
+ fileName, _ = QFileDialog.getSaveFileName(self, "QFileDialog.getSaveFileName()",
+ self._save_file_name_label.text(),
+ "All Files (*);;Text Files (*.txt)", "", options)
if fileName:
self._save_file_name_label.setText(fileName)
+ @Slot()
def critical_message(self):
- reply = QMessageBox.critical(self, "QMessageBox.critical()",
- Dialog.MESSAGE,
- QMessageBox.Abort | QMessageBox.Retry | QMessageBox.Ignore)
+ m = dedent("""\
+ Activating the liquid oxygen stirring fans caused an
+ explosion in one of the tanks. Liquid oxygen levels
+ are getting low. This may jeopardize the moon landing mission.""")
+ msg_box = QMessageBox(QMessageBox.Critical, "QMessageBox.critical()",
+ "Houston, we have a problem",
+ QMessageBox.Abort | QMessageBox.Retry | QMessageBox.Ignore,
+ self)
+ msg_box.setInformativeText(m)
+ reply = msg_box.exec()
if reply == QMessageBox.Abort:
self._critical_label.setText("Abort")
elif reply == QMessageBox.Retry:
@@ -349,18 +358,36 @@ class Dialog(QDialog):
else:
self._critical_label.setText("Ignore")
+ @Slot()
def information_message(self):
- reply = QMessageBox.information(self,
- "QMessageBox.information()", Dialog.MESSAGE)
+ m = dedent("""\
+ This phrase was often used by public address announcers at
+ the conclusion of Elvis Presley concerts in order to
+ disperse audiences who lingered in hopes of an encore.
+ It has since become a catchphrase and punchline.""")
+ msg_box = QMessageBox(QMessageBox.Information, "QMessageBox.information()",
+ "Elvis has left the building.",
+ QMessageBox.Ok, self)
+ msg_box.setInformativeText(m)
+ reply = msg_box.exec()
if reply == QMessageBox.Ok:
self._information_label.setText("OK")
else:
self._information_label.setText("Escape")
+ @Slot()
def question_message(self):
- reply = QMessageBox.question(self, "QMessageBox.question()",
- Dialog.MESSAGE,
- QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
+ m = dedent("""\
+ A cheeseburger is a hamburger topped with cheese.
+ Traditionally, the slice of cheese is placed on top of the
+ meat patty. The cheese is usually added to the cooking
+ hamburger patty shortly before serving, which allows the
+ cheese to melt.""")
+ msg_box = QMessageBox(QMessageBox.Question, "QMessageBox.question()",
+ "Would you like cheese with that?",
+ QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
+ msg_box.setInformativeText(m)
+ reply = msg_box.exec()
if reply == QMessageBox.Yes:
self._question_label.setText("Yes")
elif reply == QMessageBox.No:
@@ -368,25 +395,36 @@ class Dialog(QDialog):
else:
self._question_label.setText("Cancel")
+ @Slot()
def warning_message(self):
- msg_box = QMessageBox(QMessageBox.Warning,
- "QMessageBox.warning()", Dialog.MESSAGE,
- QMessageBox.NoButton, self)
- msg_box.addButton("Save &Again", QMessageBox.AcceptRole)
- msg_box.addButton("&Continue", QMessageBox.RejectRole)
+ msg_box = QMessageBox(QMessageBox.Warning, "QMessageBox.warning()",
+ "Delete the only copy of your movie manuscript?",
+ QMessageBox.NoButton, self)
+ m = "You've been working on this manuscript for 738 days now. Hang in there!"
+ msg_box.setInformativeText(m)
+ msg_box.setDetailedText('"A long time ago in a galaxy far, far away...."')
+ msg_box.addButton("&Keep", QMessageBox.AcceptRole)
+ msg_box.addButton("Delete", QMessageBox.RejectRole)
if msg_box.exec() == QMessageBox.AcceptRole:
- self._warning_label.setText("Save Again")
+ self._warning_label.setText("Keep")
else:
- self._warning_label.setText("Continue")
+ self._warning_label.setText("Delete")
+ @Slot()
def error_message(self):
- self._error_message_dialog.showMessage("This dialog shows and remembers "
- "error messages. If the checkbox is checked (as it is by "
- "default), the shown message will be shown again, but if the "
- "user unchecks the box the message will not appear again if "
- "QErrorMessage.showMessage() is called with the same message.")
- self._error_label.setText("If the box is unchecked, the message won't "
- "appear again.")
+ m = dedent("""\
+ This dialog shows and remembers error messages. If the
+ user chooses to not show the dialog again, the dialog
+ will not appear again if QErrorMessage.showMessage()
+ is called with the same message.""")
+ self._error_message_dialog.showMessage(m)
+ m = dedent("""\
+ You can queue up error messages, and they will be
+ shown one after each other. Each message maintains
+ its own state for whether it will be shown again
+ the next time QErrorMessage::showMessage() is called
+ with the same message.""")
+ self._error_message_dialog.showMessage(m)
if __name__ == '__main__':
diff --git a/examples/widgets/dialogs/trivialwizard/trivialwizard.py b/examples/widgets/dialogs/trivialwizard/trivialwizard.py
index a0baa6ba4..2e551ae19 100644
--- a/examples/widgets/dialogs/trivialwizard/trivialwizard.py
+++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.py
@@ -7,7 +7,7 @@
import sys
from PySide6.QtWidgets import (QApplication, QFormLayout, QLabel, QLineEdit,
- QVBoxLayout, QWidget, QWizardPage, QWizard)
+ QVBoxLayout, QWizardPage, QWizard)
def create_intro_page():
@@ -15,7 +15,7 @@ def create_intro_page():
page.setTitle("Introduction")
label = QLabel("This wizard will help you register your copy of "
- "Super Product Two.")
+ "Super Product Two.")
label.setWordWrap(True)
layout = QVBoxLayout(page)
diff --git a/examples/widgets/draganddrop/draggabletext/draggabletext.py b/examples/widgets/draganddrop/draggabletext/draggabletext.py
index 4b470cc9d..6ffdbd70e 100644
--- a/examples/widgets/draganddrop/draggabletext/draggabletext.py
+++ b/examples/widgets/draganddrop/draggabletext/draggabletext.py
@@ -2,13 +2,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-"""PySide6 port of the widgets/draganddrop/draggabletext example from Qt v5.x, originating from PyQt"""
+"""PySide6 port of the widgets/draganddrop/draggabletext example from Qt v5.x,
+ originating from PyQt"""
from PySide6.QtCore import QFile, QIODevice, QMimeData, QPoint, Qt, QTextStream
from PySide6.QtGui import QDrag, QPalette, QPixmap
from PySide6.QtWidgets import QApplication, QFrame, QLabel, QWidget
-import draggabletext_rc
+import draggabletext_rc # noqa: F401
class DragLabel(QLabel):
diff --git a/examples/widgets/draganddrop/draggabletext/draggabletext.pyproject b/examples/widgets/draganddrop/draggabletext/draggabletext.pyproject
index 0d422076e..fd97c9096 100644
--- a/examples/widgets/draganddrop/draggabletext/draggabletext.pyproject
+++ b/examples/widgets/draganddrop/draggabletext/draggabletext.pyproject
@@ -1,4 +1,3 @@
{
- "files": ["draggabletext_rc.py", "words.txt", "draggabletext.qrc",
- "draggabletext.py"]
+ "files": ["words.txt", "draggabletext.qrc", "draggabletext.py"]
}
diff --git a/examples/widgets/draganddrop/dropsite/doc/dropsite.rst b/examples/widgets/draganddrop/dropsite/doc/dropsite.rst
new file mode 100644
index 000000000..8d6c42bc8
--- /dev/null
+++ b/examples/widgets/draganddrop/dropsite/doc/dropsite.rst
@@ -0,0 +1,8 @@
+Drop Site Example
+=================
+
+The Drop Site example shows how to distinguish the various MIME formats
+available in a drag and drop operation.
+
+It accepts drops from other applications and displays the MIME formats
+provided by the drag object.
diff --git a/examples/widgets/draganddrop/dropsite/droparea.py b/examples/widgets/draganddrop/dropsite/droparea.py
new file mode 100644
index 000000000..efc4614f0
--- /dev/null
+++ b/examples/widgets/draganddrop/dropsite/droparea.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from PySide6.QtCore import QMimeData, Qt, Slot, Signal
+from PySide6.QtGui import QPalette, QPixmap
+from PySide6.QtWidgets import QFrame, QLabel
+
+
+class DropArea(QLabel):
+
+ changed = Signal(QMimeData)
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setMinimumSize(200, 200)
+ self.setFrameStyle(QFrame.Sunken | QFrame.StyledPanel)
+ self.setAlignment(Qt.AlignCenter)
+ self.setAcceptDrops(True)
+ self.setAutoFillBackground(True)
+ self.clear()
+
+ def dragEnterEvent(self, event):
+ self.setText("<drop content>")
+ self.setBackgroundRole(QPalette.Highlight)
+
+ event.acceptProposedAction()
+ self.changed.emit(event.mimeData())
+
+ def dragMoveEvent(self, event):
+ event.acceptProposedAction()
+
+ def dropEvent(self, event):
+ mime_data = event.mimeData()
+
+ if mime_data.hasImage():
+ self.setPixmap(QPixmap(mime_data.imageData()))
+ elif mime_data.hasFormat("text/markdown"):
+ self.setText(mime_data.data("text/markdown"))
+ self.setTextFormat(Qt.MarkdownText)
+ elif mime_data.hasHtml():
+ self.setText(mime_data.html())
+ self.setTextFormat(Qt.RichText)
+ elif mime_data.hasText():
+ self.setText(mime_data.text())
+ self.setTextFormat(Qt.PlainText)
+ elif mime_data.hasUrls():
+ url_list = mime_data.urls()
+ text = ""
+ for i in range(0, min(len(url_list), 32)):
+ text += url_list[i].path() + "\n"
+ self.setText(text)
+ else:
+ self.setText("Cannot display data")
+
+ self.setBackgroundRole(QPalette.Dark)
+ event.acceptProposedAction()
+
+ def dragLeaveEvent(self, event):
+ self.clear()
+ event.accept()
+
+ @Slot()
+ def clear(self):
+ self.setText("<drop content>")
+ self.setBackgroundRole(QPalette.Dark)
+
+ self.changed.emit(None)
diff --git a/examples/widgets/draganddrop/dropsite/dropsite.pyproject b/examples/widgets/draganddrop/dropsite/dropsite.pyproject
new file mode 100644
index 000000000..0173d5cb9
--- /dev/null
+++ b/examples/widgets/draganddrop/dropsite/dropsite.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["main.py", "droparea.py", "dropsitewindow.py"]
+}
diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.py b/examples/widgets/draganddrop/dropsite/dropsitewindow.py
new file mode 100644
index 000000000..5427d520d
--- /dev/null
+++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.py
@@ -0,0 +1,115 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import re
+from PySide6.QtCore import QMimeData, Qt, Slot
+from PySide6.QtGui import QGuiApplication
+from PySide6.QtWidgets import (QAbstractItemView, QPushButton,
+ QDialogButtonBox, QLabel,
+ QTableWidget, QTableWidgetItem,
+ QVBoxLayout, QWidget)
+
+from droparea import DropArea
+
+DESCRIPTION = """This example accepts drags from other applications and
+displays the MIME types provided by the drag object."""
+
+
+_WHITESPACE_PATTERN = re.compile(r"\s+")
+
+
+def simplify_whitespace(s):
+ return _WHITESPACE_PATTERN.sub(" ", s).strip()
+
+
+class DropSiteWindow(QWidget):
+
+ def __init__(self):
+ super().__init__()
+ drop_area = DropArea()
+ abstract_label = QLabel()
+ self._formats_table = QTableWidget()
+
+ button_box = QDialogButtonBox()
+ abstract_label = QLabel(DESCRIPTION)
+ abstract_label.setWordWrap(True)
+ abstract_label.adjustSize()
+
+ drop_area = DropArea()
+ drop_area.changed.connect(self.update_formats_table)
+
+ self._formats_table = QTableWidget()
+ self._formats_table.setColumnCount(2)
+ self._formats_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
+ self._formats_table.setHorizontalHeaderLabels(["Format", "Content"])
+ self._formats_table.horizontalHeader().setStretchLastSection(True)
+
+ clear_button = QPushButton("Clear")
+ self._copy_button = QPushButton("Copy")
+ quit_button = QPushButton("Quit")
+
+ button_box = QDialogButtonBox()
+ button_box.addButton(clear_button, QDialogButtonBox.ActionRole)
+ button_box.addButton(self._copy_button, QDialogButtonBox.ActionRole)
+ self._copy_button.setVisible(False)
+
+ button_box.addButton(quit_button, QDialogButtonBox.RejectRole)
+
+ quit_button.clicked.connect(self.close)
+ clear_button.clicked.connect(drop_area.clear)
+ self._copy_button.clicked.connect(self.copy)
+
+ main_layout = QVBoxLayout(self)
+ main_layout.addWidget(abstract_label)
+ main_layout.addWidget(drop_area)
+ main_layout.addWidget(self._formats_table)
+ main_layout.addWidget(button_box)
+
+ self.setWindowTitle("Drop Site")
+ self.resize(700, 500)
+
+ @Slot(QMimeData)
+ def update_formats_table(self, mime_data):
+ self._formats_table.setRowCount(0)
+ self._copy_button.setEnabled(False)
+ if not mime_data:
+ return
+
+ for format in mime_data.formats():
+ format_item = QTableWidgetItem(format)
+ format_item.setFlags(Qt.ItemIsEnabled)
+ format_item.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)
+
+ if format == "text/plain":
+ text = simplify_whitespace(mime_data.text())
+ elif format == "text/markdown":
+ text = mime_data.data("text/markdown").data().decode("utf8")
+ elif format == "text/html":
+ text = simplify_whitespace(mime_data.html())
+ elif format == "text/uri-list":
+ url_list = mime_data.urls()
+ text = ""
+ for i in range(0, min(len(url_list), 32)):
+ text += url_list[i].toString() + " "
+ else:
+ data = mime_data.data(format)
+ if data.size() > 32:
+ data.truncate(32)
+ text = data.toHex(" ").data().decode("utf8").upper()
+
+ row = self._formats_table.rowCount()
+ self._formats_table.insertRow(row)
+ self._formats_table.setItem(row, 0, QTableWidgetItem(format))
+ self._formats_table.setItem(row, 1, QTableWidgetItem(text))
+
+ self._formats_table.resizeColumnToContents(0)
+ self._copy_button.setEnabled(self._formats_table.rowCount() > 0)
+
+ @Slot()
+ def copy(self):
+ text = ""
+ for row in range(0, self._formats_table.rowCount()):
+ c1 = self._formats_table.item(row, 0).text()
+ c2 = self._formats_table.item(row, 1).text()
+ text += f"{c1}: {c2}\n"
+ QGuiApplication.clipboard().setText(text)
diff --git a/examples/widgets/codeeditor/main.py b/examples/widgets/draganddrop/dropsite/main.py
index cffcca02c..bce476a61 100644
--- a/examples/widgets/codeeditor/main.py
+++ b/examples/widgets/draganddrop/dropsite/main.py
@@ -2,14 +2,14 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import sys
+
from PySide6.QtWidgets import QApplication
-from codeeditor import CodeEditor
-"""PySide6 port of the widgets/codeeditor example from Qt5"""
+from dropsitewindow import DropSiteWindow
+
if __name__ == "__main__":
- app = QApplication([])
- editor = CodeEditor()
- editor.setWindowTitle("Code Editor Example")
- editor.show()
+ app = QApplication(sys.argv)
+ window = DropSiteWindow()
+ window.show()
sys.exit(app.exec())
diff --git a/examples/widgets/effects/lighting/lighting.py b/examples/widgets/effects/lighting/lighting.py
index 5328058fe..f074813c3 100644
--- a/examples/widgets/effects/lighting/lighting.py
+++ b/examples/widgets/effects/lighting/lighting.py
@@ -10,7 +10,7 @@ from PySide6.QtGui import (QBrush, QColor, QLinearGradient, QPainter, QPen,
QPixmap, QRadialGradient)
from PySide6.QtWidgets import (QApplication, QFrame, QGraphicsDropShadowEffect,
QGraphicsEllipseItem, QGraphicsRectItem,
- QGraphicsScene, QGraphicsView, QWidget)
+ QGraphicsScene, QGraphicsView)
class Lighting(QGraphicsView):
@@ -37,8 +37,7 @@ class Lighting(QGraphicsView):
def setup_scene(self):
self.m_scene.setSceneRect(-300, -200, 600, 460)
- linear_grad = QLinearGradient(QPointF(-100, -100),
- QPointF(100, 100))
+ linear_grad = QLinearGradient(QPointF(-100, -100), QPointF(100, 100))
linear_grad.setColorAt(0, QColor(255, 255, 255))
linear_grad.setColorAt(1, QColor(192, 192, 255))
self.setBackgroundBrush(linear_grad)
diff --git a/examples/widgets/gettext/doc/gettext.rst b/examples/widgets/gettext/doc/gettext.rst
new file mode 100644
index 000000000..ea1127fe7
--- /dev/null
+++ b/examples/widgets/gettext/doc/gettext.rst
@@ -0,0 +1,7 @@
+.. _gettext-example:
+
+GNU gettext Example
+===================
+
+This example demonstrates the use of GNU gettext for translating
+applications as described in :ref:`translations`.
diff --git a/examples/widgets/gettext/main.py b/examples/widgets/gettext/main.py
index 2e402d49c..85695728d 100644
--- a/examples/widgets/gettext/main.py
+++ b/examples/widgets/gettext/main.py
@@ -5,9 +5,9 @@ from pathlib import Path
import gettext
import sys
-from PySide6.QtCore import QItemSelection, QLocale, Qt, Slot
+from PySide6.QtCore import QItemSelection, Slot
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QListWidget,
- QMainWindow, QWidget)
+ QMainWindow)
_ = None
diff --git a/examples/widgets/graphicsview/anchorlayout/anchorlayout.py b/examples/widgets/graphicsview/anchorlayout/anchorlayout.py
index 0fbc801ae..9d9be041f 100644
--- a/examples/widgets/graphicsview/anchorlayout/anchorlayout.py
+++ b/examples/widgets/graphicsview/anchorlayout/anchorlayout.py
@@ -8,7 +8,7 @@ from PySide6.QtCore import QSizeF, Qt
from PySide6.QtWidgets import (QApplication, QGraphicsAnchorLayout,
QGraphicsProxyWidget, QGraphicsScene,
QGraphicsView, QGraphicsWidget,
- QPushButton, QSizePolicy, QWidget)
+ QPushButton, QSizePolicy)
def create_item(minimum, preferred, maximum, name):
@@ -41,7 +41,7 @@ if __name__ == '__main__':
f = create_item(QSizeF(30, 50), QSizeF(150, 50), max_size, "F")
g = create_item(QSizeF(30, 50), QSizeF(30, 100), max_size, "G")
- l = QGraphicsAnchorLayout()
+ l = QGraphicsAnchorLayout() # noqa: E741
l.setSpacing(0)
w = QGraphicsWidget(None, Qt.Window)
diff --git a/examples/widgets/graphicsview/collidingmice/collidingmice.py b/examples/widgets/graphicsview/collidingmice/collidingmice.py
index 53c5c1aab..fb24db3ab 100644
--- a/examples/widgets/graphicsview/collidingmice/collidingmice.py
+++ b/examples/widgets/graphicsview/collidingmice/collidingmice.py
@@ -5,14 +5,11 @@
import math
import sys
-from PySide6.QtCore import (QLineF, QPointF, QRandomGenerator, QRectF, QTimer,
- Qt)
-from PySide6.QtGui import (QBrush, QColor, QPainter, QPainterPath, QPixmap,
- QPolygonF, QTransform)
-from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsScene,
- QGraphicsView)
+from PySide6.QtCore import (QLineF, QPointF, QRandomGenerator, QRectF, QTimer, Qt)
+from PySide6.QtGui import (QBrush, QColor, QPainter, QPainterPath, QPixmap, QPolygonF, QTransform)
+from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsScene, QGraphicsView)
-import mice_rc
+import mice_rc # noqa: F401
def random(boundary):
@@ -26,7 +23,7 @@ class Mouse(QGraphicsItem):
# Create the bounding rectangle once.
adjust = 0.5
BOUNDING_RECT = QRectF(-20 - adjust, -22 - adjust, 40 + adjust,
- 83 + adjust)
+ 83 + adjust)
def __init__(self):
super().__init__()
@@ -103,7 +100,8 @@ class Mouse(QGraphicsItem):
if angle_to_center < Mouse.PI and angle_to_center > Mouse.PI / 4:
# Rotate left.
self.angle += [-0.25, 0.25][self.angle < -Mouse.PI / 2]
- elif angle_to_center >= Mouse.PI and angle_to_center < (Mouse.PI + Mouse.PI / 2 + Mouse.PI / 4):
+ elif (angle_to_center >= Mouse.PI
+ and angle_to_center < (Mouse.PI + Mouse.PI / 2 + Mouse.PI / 4)):
# Rotate right.
self.angle += [-0.25, 0.25][self.angle < Mouse.PI / 2]
elif math.sin(self.angle) < 0:
diff --git a/examples/widgets/graphicsview/collidingmice/collidingmice.pyproject b/examples/widgets/graphicsview/collidingmice/collidingmice.pyproject
index ea5821866..621bfd642 100644
--- a/examples/widgets/graphicsview/collidingmice/collidingmice.pyproject
+++ b/examples/widgets/graphicsview/collidingmice/collidingmice.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["collidingmice.py", "mice_rc.py"]
+ "files": ["collidingmice.py"]
}
diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.py b/examples/widgets/graphicsview/diagramscene/diagramscene.py
index e653285c4..60e05613c 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramscene.py
+++ b/examples/widgets/graphicsview/diagramscene/diagramscene.py
@@ -6,19 +6,18 @@ import math
import sys
from PySide6.QtCore import (QLineF, QPointF, QRect, QRectF, QSize, QSizeF, Qt,
- Signal)
-from PySide6.QtGui import (QAction, QColor, QFont, QIcon, QIntValidator,
+ Signal, Slot)
+from PySide6.QtGui import (QAction, QBrush, QColor, QFont, QIcon, QIntValidator,
QPainter, QPainterPath, QPen, QPixmap, QPolygonF)
-from PySide6.QtWidgets import (QApplication, QButtonGroup, QComboBox,
- QFontComboBox, QGraphicsAnchorLayout,
- QGraphicsItem, QGraphicsLineItem,
+from PySide6.QtWidgets import (QAbstractButton, QApplication, QButtonGroup,
+ QComboBox, QFontComboBox, QGraphicsItem, QGraphicsLineItem,
QGraphicsPolygonItem, QGraphicsTextItem,
QGraphicsScene, QGraphicsView, QGridLayout,
QHBoxLayout, QLabel, QMainWindow, QMenu,
QMessageBox, QSizePolicy, QToolBox, QToolButton,
QWidget)
-import diagramscene_rc
+import diagramscene_rc # noqa: F401
class Arrow(QGraphicsLineItem):
@@ -31,8 +30,7 @@ class Arrow(QGraphicsLineItem):
self._my_end_item = endItem
self.setFlag(QGraphicsItem.ItemIsSelectable, True)
self._my_color = Qt.black
- self.setPen(QPen(self._my_color, 2, Qt.SolidLine,
- Qt.RoundCap, Qt.RoundJoin))
+ self.setPen(QPen(self._my_color, 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
def set_color(self, color):
self._my_color = color
@@ -164,19 +162,19 @@ class DiagramItem(QGraphicsPolygonItem):
self._my_polygon = path.toFillPolygon()
elif self.diagram_type == self.Conditional:
self._my_polygon = QPolygonF([
- QPointF(-100, 0), QPointF(0, 100),
- QPointF(100, 0), QPointF(0, -100),
- QPointF(-100, 0)])
+ QPointF(-100, 0), QPointF(0, 100),
+ QPointF(100, 0), QPointF(0, -100),
+ QPointF(-100, 0)])
elif self.diagram_type == self.Step:
self._my_polygon = QPolygonF([
- QPointF(-100, -100), QPointF(100, -100),
- QPointF(100, 100), QPointF(-100, 100),
- QPointF(-100, -100)])
+ QPointF(-100, -100), QPointF(100, -100),
+ QPointF(100, 100), QPointF(-100, 100),
+ QPointF(-100, -100)])
else:
self._my_polygon = QPolygonF([
- QPointF(-120, -80), QPointF(-70, 80),
- QPointF(120, 80), QPointF(70, -80),
- QPointF(-120, -80)])
+ QPointF(-120, -80), QPointF(-70, 80),
+ QPointF(120, 80), QPointF(70, -80),
+ QPointF(-120, -80)])
self.setPolygon(self._my_polygon)
self.setFlag(QGraphicsItem.ItemIsMovable, True)
@@ -292,8 +290,7 @@ class DiagramScene(QGraphicsScene):
item.setPos(mouseEvent.scenePos())
self.item_inserted.emit(item)
elif self._my_mode == self.InsertLine:
- self.line = QGraphicsLineItem(QLineF(mouseEvent.scenePos(),
- mouseEvent.scenePos()))
+ self.line = QGraphicsLineItem(QLineF(mouseEvent.scenePos(), mouseEvent.scenePos()))
self.line.setPen(QPen(self._my_line_color, 2))
self.addItem(self.line)
elif self._my_mode == self.InsertText:
@@ -329,10 +326,10 @@ class DiagramScene(QGraphicsScene):
self.removeItem(self.line)
self.line = None
- if (len(start_items) and len(end_items) and
- isinstance(start_items[0], DiagramItem) and
- isinstance(end_items[0], DiagramItem) and
- start_items[0] != end_items[0]):
+ if (len(start_items) and len(end_items)
+ and isinstance(start_items[0], DiagramItem)
+ and isinstance(end_items[0], DiagramItem)
+ and start_items[0] != end_items[0]):
start_item = start_items[0]
end_item = end_items[0]
arrow = Arrow(start_item, end_item)
@@ -382,6 +379,7 @@ class MainWindow(QMainWindow):
self.setCentralWidget(self.widget)
self.setWindowTitle("Diagramscene")
+ @Slot(QAbstractButton)
def background_button_group_clicked(self, button):
buttons = self._background_button_group.buttons()
for myButton in buttons:
@@ -401,6 +399,7 @@ class MainWindow(QMainWindow):
self.scene.update()
self.view.update()
+ @Slot(int)
def button_group_clicked(self, idx):
buttons = self._button_group.buttons()
for button in buttons:
@@ -413,15 +412,18 @@ class MainWindow(QMainWindow):
self.scene.set_item_type(idx)
self.scene.set_mode(DiagramScene.InsertItem)
+ @Slot()
def delete_item(self):
for item in self.scene.selectedItems():
if isinstance(item, DiagramItem):
item.remove_arrows()
self.scene.removeItem(item)
+ @Slot(int)
def pointer_group_clicked(self, i):
self.scene.set_mode(self._pointer_type_group.checkedId())
+ @Slot()
def bring_to_front(self):
if not self.scene.selectedItems():
return
@@ -435,6 +437,7 @@ class MainWindow(QMainWindow):
z_value = item.zValue() + 0.1
selected_item.setZValue(z_value)
+ @Slot()
def send_to_back(self):
if not self.scene.selectedItems():
return
@@ -448,21 +451,26 @@ class MainWindow(QMainWindow):
z_value = item.zValue() - 0.1
selected_item.setZValue(z_value)
+ @Slot(QGraphicsPolygonItem)
def item_inserted(self, item):
self._pointer_type_group.button(DiagramScene.MoveItem).setChecked(True)
self.scene.set_mode(self._pointer_type_group.checkedId())
self._button_group.button(item.diagram_type).setChecked(False)
+ @Slot(QGraphicsTextItem)
def text_inserted(self, item):
self._button_group.button(self.insert_text_button).setChecked(False)
self.scene.set_mode(self._pointer_type_group.checkedId())
+ @Slot(QFont)
def current_font_changed(self, font):
self.handle_font_change()
+ @Slot(int)
def font_size_changed(self, font):
self.handle_font_change()
+ @Slot(str)
def scene_scale_changed(self, scale):
new_scale = int(scale[:-1]) / 100.0
old_matrix = self.view.transform()
@@ -470,36 +478,40 @@ class MainWindow(QMainWindow):
self.view.translate(old_matrix.dx(), old_matrix.dy())
self.view.scale(new_scale, new_scale)
+ @Slot()
def text_color_changed(self):
self._text_action = self.sender()
self._font_color_tool_button.setIcon(self.create_color_tool_button_icon(
- ':/images/textpointer.png',
- QColor(self._text_action.data())))
+ ':/images/textpointer.png', QColor(self._text_action.data())))
self.text_button_triggered()
+ @Slot()
def item_color_changed(self):
self._fill_action = self.sender()
self._fill_color_tool_button.setIcon(self.create_color_tool_button_icon(
- ':/images/floodfill.png',
- QColor(self._fill_action.data())))
+ ':/images/floodfill.png', QColor(self._fill_action.data())))
self.fill_button_triggered()
+ @Slot()
def line_color_changed(self):
self._line_action = self.sender()
self._line_color_tool_button.setIcon(self.create_color_tool_button_icon(
- ':/images/linecolor.png',
- QColor(self._line_action.data())))
+ ':/images/linecolor.png', QColor(self._line_action.data())))
self.line_button_triggered()
+ @Slot()
def text_button_triggered(self):
self.scene.set_text_color(QColor(self._text_action.data()))
+ @Slot()
def fill_button_triggered(self):
self.scene.set_item_color(QColor(self._fill_action.data()))
+ @Slot()
def line_button_triggered(self):
self.scene.set_line_color(QColor(self._line_action.data()))
+ @Slot()
def handle_font_change(self):
font = self._font_combo.currentFont()
font.setPointSize(int(self._font_size_combo.currentText()))
@@ -512,18 +524,19 @@ class MainWindow(QMainWindow):
self.scene.set_font(font)
+ @Slot(QGraphicsItem)
def item_selected(self, item):
font = item.font()
- color = item.defaultTextColor()
self._font_combo.setCurrentFont(font)
self._font_size_combo.setEditText(str(font.pointSize()))
self._bold_action.setChecked(font.weight() == QFont.Bold)
self._italic_action.setChecked(font.italic())
self._underline_action.setChecked(font.underline())
+ @Slot()
def about(self):
QMessageBox.about(self, "About Diagram Scene",
- "The <b>Diagram Scene</b> example shows use of the graphics framework.")
+ "The <b>Diagram Scene</b> example shows use of the graphics framework.")
def create_tool_box(self):
self._button_group = QButtonGroup()
@@ -531,12 +544,9 @@ class MainWindow(QMainWindow):
self._button_group.idClicked.connect(self.button_group_clicked)
layout = QGridLayout()
- layout.addWidget(self.create_cell_widget("Conditional", DiagramItem.Conditional),
- 0, 0)
- layout.addWidget(self.create_cell_widget("Process", DiagramItem.Step), 0,
- 1)
- layout.addWidget(self.create_cell_widget("Input/Output", DiagramItem.Io),
- 1, 0)
+ layout.addWidget(self.create_cell_widget("Conditional", DiagramItem.Conditional), 0, 0)
+ layout.addWidget(self.create_cell_widget("Process", DiagramItem.Step), 0, 1)
+ layout.addWidget(self.create_cell_widget("Input/Output", DiagramItem.Io), 1, 0)
text_button = QToolButton()
text_button.setCheckable(True)
@@ -562,14 +572,14 @@ class MainWindow(QMainWindow):
self._background_button_group.buttonClicked.connect(self.background_button_group_clicked)
background_layout = QGridLayout()
- background_layout.addWidget(self.create_background_cell_widget("Blue Grid",
- ':/images/background1.png'), 0, 0)
- background_layout.addWidget(self.create_background_cell_widget("White Grid",
- ':/images/background2.png'), 0, 1)
- background_layout.addWidget(self.create_background_cell_widget("Gray Grid",
- ':/images/background3.png'), 1, 0)
- background_layout.addWidget(self.create_background_cell_widget("No Grid",
- ':/images/background4.png'), 1, 1)
+ background_layout.addWidget(
+ self.create_background_cell_widget("Blue Grid", ':/images/background1.png'), 0, 0)
+ background_layout.addWidget(
+ self.create_background_cell_widget("White Grid", ':/images/background2.png'), 0, 1)
+ background_layout.addWidget(
+ self.create_background_cell_widget("Gray Grid", ':/images/background3.png'), 1, 0)
+ background_layout.addWidget(
+ self.create_background_cell_widget("No Grid", ':/images/background4.png'), 1, 1)
background_layout.setRowStretch(2, 10)
background_layout.setColumnStretch(2, 10)
@@ -585,38 +595,37 @@ class MainWindow(QMainWindow):
def create_actions(self):
self._to_front_action = QAction(
- QIcon(':/images/bringtofront.png'), "Bring to &Front",
- self, shortcut="Ctrl+F", statusTip="Bring item to front",
- triggered=self.bring_to_front)
+ QIcon(':/images/bringtofront.png'), "Bring to &Front",
+ self, shortcut="Ctrl+F", statusTip="Bring item to front",
+ triggered=self.bring_to_front)
self._send_back_action = QAction(
- QIcon(':/images/sendtoback.png'), "Send to &Back", self,
- shortcut="Ctrl+B", statusTip="Send item to back",
- triggered=self.send_to_back)
+ QIcon(':/images/sendtoback.png'), "Send to &Back", self,
+ shortcut="Ctrl+B", statusTip="Send item to back",
+ triggered=self.send_to_back)
self._delete_action = QAction(QIcon(':/images/delete.png'),
- "&Delete", self, shortcut="Delete",
- statusTip="Delete item from diagram",
- triggered=self.delete_item)
+ "&Delete", self, shortcut="Delete",
+ statusTip="Delete item from diagram",
+ triggered=self.delete_item)
self._exit_action = QAction("E&xit", self, shortcut="Ctrl+X",
- statusTip="Quit Scenediagram example", triggered=self.close)
+ statusTip="Quit Scenediagram example", triggered=self.close)
self._bold_action = QAction(QIcon(':/images/bold.png'),
- "Bold", self, checkable=True, shortcut="Ctrl+B",
- triggered=self.handle_font_change)
+ "Bold", self, checkable=True, shortcut="Ctrl+B",
+ triggered=self.handle_font_change)
self._italic_action = QAction(QIcon(':/images/italic.png'),
- "Italic", self, checkable=True, shortcut="Ctrl+I",
- triggered=self.handle_font_change)
+ "Italic", self, checkable=True, shortcut="Ctrl+I",
+ triggered=self.handle_font_change)
self._underline_action = QAction(
- QIcon(':/images/underline.png'), "Underline", self,
- checkable=True, shortcut="Ctrl+U",
- triggered=self.handle_font_change)
+ QIcon(':/images/underline.png'), "Underline", self,
+ checkable=True, shortcut="Ctrl+U",
+ triggered=self.handle_font_change)
- self._about_action = QAction("A&bout", self, shortcut="Ctrl+B",
- triggered=self.about)
+ self._about_action = QAction("A&bout", self, shortcut="Ctrl+B", triggered=self.about)
def create_menus(self):
self._file_menu = self.menuBar().addMenu("&File")
@@ -651,32 +660,29 @@ class MainWindow(QMainWindow):
self._font_color_tool_button = QToolButton()
self._font_color_tool_button.setPopupMode(QToolButton.MenuButtonPopup)
self._font_color_tool_button.setMenu(
- self.create_color_menu(self.text_color_changed, Qt.black))
+ self.create_color_menu(self.text_color_changed, Qt.black))
self._text_action = self._font_color_tool_button.menu().defaultAction()
self._font_color_tool_button.setIcon(
- self.create_color_tool_button_icon(':/images/textpointer.png',
- Qt.black))
+ self.create_color_tool_button_icon(':/images/textpointer.png', Qt.black))
self._font_color_tool_button.setAutoFillBackground(True)
self._font_color_tool_button.clicked.connect(self.text_button_triggered)
self._fill_color_tool_button = QToolButton()
self._fill_color_tool_button.setPopupMode(QToolButton.MenuButtonPopup)
self._fill_color_tool_button.setMenu(
- self.create_color_menu(self.item_color_changed, Qt.white))
+ self.create_color_menu(self.item_color_changed, Qt.white))
self._fill_action = self._fill_color_tool_button.menu().defaultAction()
self._fill_color_tool_button.setIcon(
- self.create_color_tool_button_icon(':/images/floodfill.png',
- Qt.white))
+ self.create_color_tool_button_icon(':/images/floodfill.png', Qt.white))
self._fill_color_tool_button.clicked.connect(self.fill_button_triggered)
self._line_color_tool_button = QToolButton()
self._line_color_tool_button.setPopupMode(QToolButton.MenuButtonPopup)
self._line_color_tool_button.setMenu(
- self.create_color_menu(self.line_color_changed, Qt.black))
+ self.create_color_menu(self.line_color_changed, Qt.black))
self._line_action = self._line_color_tool_button.menu().defaultAction()
self._line_color_tool_button.setIcon(
- self.create_color_tool_button_icon(':/images/linecolor.png',
- Qt.black))
+ self.create_color_tool_button_icon(':/images/linecolor.png', Qt.black))
self._line_color_tool_button.clicked.connect(self.line_button_triggered)
self._text_tool_bar = self.addToolBar("Font")
@@ -701,8 +707,7 @@ class MainWindow(QMainWindow):
self._pointer_type_group = QButtonGroup()
self._pointer_type_group.addButton(pointer_button, DiagramScene.MoveItem)
- self._pointer_type_group.addButton(line_pointer_button,
- DiagramScene.InsertLine)
+ self._pointer_type_group.addButton(line_pointer_button, DiagramScene.InsertLine)
self._pointer_type_group.idClicked.connect(self.pointer_group_clicked)
self._scene_scale_combo = QComboBox()
@@ -757,8 +762,7 @@ class MainWindow(QMainWindow):
color_menu = QMenu(self)
for color, name in zip(colors, names):
- action = QAction(self.create_color_icon(color), name, self,
- triggered=slot)
+ action = QAction(self.create_color_icon(color), name, self, triggered=slot)
action.setData(QColor(color))
color_menu.addAction(action)
if color == defaultColor:
diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.pyproject b/examples/widgets/graphicsview/diagramscene/diagramscene.pyproject
index 0acabdd78..79b8c8658 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramscene.pyproject
+++ b/examples/widgets/graphicsview/diagramscene/diagramscene.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["diagramscene.qrc", "diagramscene.py", "diagramscene_rc.py"]
+ "files": ["diagramscene.qrc", "diagramscene.py"]
}
diff --git a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
index 6eba05acc..9ed92b26e 100644
--- a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
+++ b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
@@ -11,9 +11,9 @@ from PySide6.QtGui import (QBrush, QColor, QDrag, QImage, QPainter, QPixmap,
QPen, QTransform)
from PySide6.QtWidgets import (QApplication, QGraphicsItem,
QGraphicsItemAnimation, QGraphicsScene,
- QGraphicsView, QWidget)
+ QGraphicsView)
-import dragdroprobot_rc
+import dragdroprobot_rc # noqa: F401
def random(boundary):
@@ -103,8 +103,8 @@ class RobotPart(QGraphicsItem):
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
- if (event.mimeData().hasColor() or
- (isinstance(self, RobotHead) and event.mimeData().hasImage())):
+ if (event.mimeData().hasColor()
+ or (isinstance(self, RobotHead) and event.mimeData().hasImage())):
event.setAccepted(True)
self._drag_over = True
self.update()
@@ -131,8 +131,7 @@ class RobotHead(RobotPart):
def paint(self, painter, option, widget=None):
if not self.pixmap:
- painter.setBrush(self._drag_over and self.color.lighter(130)
- or self.color)
+ painter.setBrush(self._drag_over and self.color.lighter(130) or self.color)
painter.drawRoundedRect(-10, -30, 20, 30, 25, 25, Qt.RelativeSize)
painter.setBrush(Qt.white)
painter.drawEllipse(-7, -3 - 20, 7, 7)
@@ -154,7 +153,7 @@ class RobotTorso(RobotPart):
def paint(self, painter, option, widget=None):
painter.setBrush(self._drag_over and self.color.lighter(130)
- or self.color)
+ or self.color)
painter.drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt.RelativeSize)
painter.drawEllipse(-25, -20, 20, 20)
painter.drawEllipse(5, -20, 20, 20)
@@ -169,7 +168,7 @@ class RobotLimb(RobotPart):
def paint(self, painter, option, widget=None):
painter.setBrush(self._drag_over and self.color.lighter(130) or self.color)
painter.drawRoundedRect(self.boundingRect(), 50, 50,
- Qt.RelativeSize)
+ Qt.RelativeSize)
painter.drawEllipse(-5, -5, 10, 10)
@@ -177,35 +176,35 @@ class Robot(RobotPart):
def __init__(self):
super().__init__()
- self.torsoItem = RobotTorso(self)
- self.headItem = RobotHead(self.torsoItem)
- self.upperLeftArmItem = RobotLimb(self.torsoItem)
- self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
+ self.torsoItem = RobotTorso(self)
+ self.headItem = RobotHead(self.torsoItem)
+ self.upperLeftArmItem = RobotLimb(self.torsoItem)
+ self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
self._upper_right_arm_item = RobotLimb(self.torsoItem)
self._lower_right_arm_item = RobotLimb(self._upper_right_arm_item)
self._upper_right_leg_item = RobotLimb(self.torsoItem)
self._lower_right_leg_item = RobotLimb(self._upper_right_leg_item)
- self.upperLeftLegItem = RobotLimb(self.torsoItem)
- self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)
+ self.upperLeftLegItem = RobotLimb(self.torsoItem)
+ self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)
self.timeline = QTimeLine()
settings = [
- # item position rotation at
- # x y time 0 / 1
- ( self.headItem, 0, -18, 20, -20 ),
- ( self.upperLeftArmItem, -15, -10, 190, 180 ),
- ( self.lowerLeftArmItem, 30, 0, 50, 10 ),
- ( self._upper_right_arm_item, 15, -10, 300, 310 ),
- ( self._lower_right_arm_item, 30, 0, 0, -70 ),
- ( self._upper_right_leg_item, 10, 32, 40, 120 ),
- ( self._lower_right_leg_item, 30, 0, 10, 50 ),
- ( self.upperLeftLegItem, -10, 32, 150, 80 ),
- ( self.lowerLeftLegItem, 30, 0, 70, 10 ),
- ( self.torsoItem, 0, 0, 5, -20 )
+ # item position rotation at
+ # x y time 0 / 1
+ (self.headItem, 0, -18, 20, -20), # noqa: E241
+ (self.upperLeftArmItem, -15, -10, 190, 180), # noqa: E241
+ (self.lowerLeftArmItem, 30, 0, 50, 10), # noqa: E241
+ (self._upper_right_arm_item, 15, -10, 300, 310), # noqa: E241
+ (self._lower_right_arm_item, 30, 0, 0, -70), # noqa: E241
+ (self._upper_right_leg_item, 10, 32, 40, 120), # noqa: E241
+ (self._lower_right_leg_item, 30, 0, 10, 50), # noqa: E241
+ (self.upperLeftLegItem, -10, 32, 150, 80), # noqa: E241
+ (self.lowerLeftLegItem, 30, 0, 70, 10), # noqa: E241
+ (self.torsoItem, 0, 0, 5, -20) # noqa: E241
]
self.animations = []
for item, pos_x, pos_y, rotation1, rotation2 in settings:
- item.setPos(pos_x,pos_y)
+ item.setPos(pos_x, pos_y)
animation = QGraphicsItemAnimation()
animation.setItem(item)
animation.setTimeLine(self.timeline)
@@ -228,7 +227,7 @@ class Robot(RobotPart):
pass
-if __name__== '__main__':
+if __name__ == '__main__':
app = QApplication(sys.argv)
scene = QGraphicsScene(-200, -200, 400, 400)
diff --git a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pyproject b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pyproject
index 587484a97..f31851b91 100644
--- a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pyproject
+++ b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["dragdroprobot.qrc", "dragdroprobot_rc.py", "dragdroprobot.py"]
+ "files": ["dragdroprobot.qrc", "dragdroprobot.py"]
}
diff --git a/examples/widgets/graphicsview/elasticnodes/elasticnodes.py b/examples/widgets/graphicsview/elasticnodes/elasticnodes.py
index b2f9eb067..90cb49626 100644
--- a/examples/widgets/graphicsview/elasticnodes/elasticnodes.py
+++ b/examples/widgets/graphicsview/elasticnodes/elasticnodes.py
@@ -8,10 +8,10 @@ import math
from PySide6.QtCore import (QLineF, QPointF, QRandomGenerator, QRectF, QSizeF,
Qt, qAbs)
-from PySide6.QtGui import (QColor, QBrush, QPainter, QPainterPath, QPen,
+from PySide6.QtGui import (QColor, QBrush, QLinearGradient, QPainter, QPainterPath, QPen,
QPolygonF, QRadialGradient)
from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsScene,
- QGraphicsView, QStyle, QWidget)
+ QGraphicsView, QStyle)
def random(boundary):
@@ -20,8 +20,6 @@ def random(boundary):
class Edge(QGraphicsItem):
- item_type = QGraphicsItem.UserType + 2
-
def __init__(self, sourceNode, destNode):
super().__init__()
@@ -36,7 +34,7 @@ class Edge(QGraphicsItem):
self.adjust()
def item_type(self):
- return Edge.item_type
+ return QGraphicsItem.UserType + 2
def source_node(self):
return self.source()
@@ -119,7 +117,6 @@ class Edge(QGraphicsItem):
class Node(QGraphicsItem):
- item_type = QGraphicsItem.UserType + 1
def __init__(self, graphWidget):
super().__init__()
@@ -129,11 +126,11 @@ class Node(QGraphicsItem):
self._new_pos = QPointF()
self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
- self.setCacheMode(self.DeviceCoordinateCache)
+ self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
self.setZValue(-1)
def item_type(self):
- return Node.item_type
+ return QGraphicsItem.UserType + 1
def add_edge(self, edge):
self._edge_list.append(weakref.ref(edge))
@@ -157,7 +154,7 @@ class Node(QGraphicsItem):
line = QLineF(self.mapFromItem(item, 0, 0), QPointF(0, 0))
dx = line.dx()
dy = line.dy()
- l = 2.0 * (dx * dx + dy * dy)
+ l = 2.0 * (dx * dx + dy * dy) # noqa: E741
if l > 0:
xvel += (dx * 150.0) / l
yvel += (dy * 150.0) / l
@@ -192,7 +189,7 @@ class Node(QGraphicsItem):
def boundingRect(self):
adjust = 2.0
return QRectF(-10 - adjust, -10 - adjust,
- 23 + adjust, 23 + adjust)
+ 23 + adjust, 23 + adjust)
def shape(self):
path = QPainterPath()
@@ -348,9 +345,9 @@ class GraphWidget(QGraphicsView):
bottom_shadow = QRectF(scene_rect.left() + 5, scene_rect.bottom(),
scene_rect.width(), 5)
if right_shadow.intersects(rect) or right_shadow.contains(rect):
- painter.fillRect(right_shadow, Qt.darkGray)
+ painter.fillRect(right_shadow, Qt.darkGray)
if bottom_shadow.intersects(rect) or bottom_shadow.contains(rect):
- painter.fillRect(bottom_shadow, Qt.darkGray)
+ painter.fillRect(bottom_shadow, Qt.darkGray)
# Fill.
gradient = QLinearGradient(scene_rect.topLeft(), scene_rect.bottomRight())
@@ -362,7 +359,7 @@ class GraphWidget(QGraphicsView):
# Text.
text_rect = QRectF(scene_rect.left() + 4, scene_rect.top() + 4,
- scene_rect.width() - 4, scene_rect.height() - 4)
+ scene_rect.width() - 4, scene_rect.height() - 4)
message = self.tr("Click and drag the nodes around, and zoom with the "
"mouse wheel or the '+' and '-' keys")
@@ -376,7 +373,8 @@ class GraphWidget(QGraphicsView):
painter.drawText(text_rect, message)
def scale_view(self, scaleFactor):
- factor = self.transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width()
+ factor = self.transform().scale(scaleFactor, scaleFactor).mapRect(
+ QRectF(0, 0, 1, 1)).width()
if factor < 0.07 or factor > 100:
return
diff --git a/examples/widgets/imageviewer/imageviewer.py b/examples/widgets/imageviewer/imageviewer.py
index 1afe0b416..93b1e87ba 100644
--- a/examples/widgets/imageviewer/imageviewer.py
+++ b/examples/widgets/imageviewer/imageviewer.py
@@ -3,12 +3,12 @@
from PySide6.QtPrintSupport import QPrintDialog, QPrinter
from PySide6.QtWidgets import (QApplication, QDialog, QFileDialog, QLabel,
- QMainWindow, QMenuBar, QMessageBox, QScrollArea,
- QScrollBar, QSizePolicy, QStatusBar)
-from PySide6.QtGui import (QAction, QClipboard, QColorSpace, QGuiApplication,
- QImage, QImageReader, QImageWriter, QKeySequence,
- QPalette, QPainter, QPixmap, QScreen)
-from PySide6.QtCore import QDir, QMimeData, QStandardPaths, Qt, Slot
+ QMainWindow, QMessageBox, QScrollArea,
+ QSizePolicy)
+from PySide6.QtGui import (QColorSpace, QGuiApplication,
+ QImageReader, QImageWriter, QKeySequence,
+ QPalette, QPainter, QPixmap)
+from PySide6.QtCore import QDir, QStandardPaths, Qt, Slot
ABOUT = """<p>The <b>Image Viewer</b> example shows how to combine QLabel
@@ -34,7 +34,7 @@ class ImageViewer(QMainWindow):
self._image_label = QLabel()
self._image_label.setBackgroundRole(QPalette.Base)
self._image_label.setSizePolicy(QSizePolicy.Ignored,
- QSizePolicy.Ignored)
+ QSizePolicy.Ignored)
self._image_label.setScaledContents(True)
self._scroll_area = QScrollArea()
diff --git a/examples/widgets/itemviews/address_book/adddialogwidget.py b/examples/widgets/itemviews/address_book/adddialogwidget.py
index 276a8d2b4..ecb853e80 100644
--- a/examples/widgets/itemviews/address_book/adddialogwidget.py
+++ b/examples/widgets/itemviews/address_book/adddialogwidget.py
@@ -15,8 +15,8 @@ class AddDialogWidget(QDialog):
name_label = QLabel("Name")
address_label = QLabel("Address")
- button_box = QDialogButtonBox(QDialogButtonBox.Ok |
- QDialogButtonBox.Cancel)
+ button_box = QDialogButtonBox(QDialogButtonBox.Ok
+ | QDialogButtonBox.Cancel)
self._name_text = QLineEdit()
self._address_text = QTextEdit()
diff --git a/examples/widgets/itemviews/address_book/address_book.py b/examples/widgets/itemviews/address_book/address_book.py
index 2121f2783..af0cf3dee 100644
--- a/examples/widgets/itemviews/address_book/address_book.py
+++ b/examples/widgets/itemviews/address_book/address_book.py
@@ -2,6 +2,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+from PySide6.QtCore import Slot
from PySide6.QtGui import QAction
from PySide6.QtWidgets import (QMainWindow, QFileDialog, QApplication)
@@ -24,16 +25,19 @@ class MainWindow(QMainWindow):
tool_menu = self.menuBar().addMenu("&Tools")
# Populate the File menu
- open_action = self.create_action("&Open...", file_menu, self.open_file)
- save_action = self.create_action("&Save As...", file_menu, self.save_file)
+ self.open_action = self.create_action("&Open...", file_menu, self.open_file)
+ self.save_action = self.create_action("&Save As...", file_menu, self.save_file)
file_menu.addSeparator()
- exit_action = self.create_action("E&xit", file_menu, self.close)
+ self.exit_action = self.create_action("E&xit", file_menu, self.close)
# Populate the Tools menu
- add_action = self.create_action("&Add Entry...", tool_menu, self._address_widget.add_entry)
- self._edit_action = self.create_action("&Edit Entry...", tool_menu, self._address_widget.edit_entry)
+ self.add_action = self.create_action(
+ "&Add Entry...", tool_menu, self._address_widget.add_entry)
+ self._edit_action = self.create_action(
+ "&Edit Entry...", tool_menu, self._address_widget.edit_entry)
tool_menu.addSeparator()
- self._remove_action = self.create_action("&Remove Entry", tool_menu, self._address_widget.remove_entry)
+ self._remove_action = self.create_action(
+ "&Remove Entry", tool_menu, self._address_widget.remove_entry)
# Disable the edit and remove menu items initially, as there are
# no items yet.
@@ -60,11 +64,13 @@ class MainWindow(QMainWindow):
#
# In PySide6, these functions return a tuple: (filename, filter)
+ @Slot()
def open_file(self):
filename, _ = QFileDialog.getOpenFileName(self)
if filename:
self._address_widget.read_from_file(filename)
+ @Slot()
def save_file(self):
filename, _ = QFileDialog.getSaveFileName(self)
if filename:
diff --git a/examples/widgets/itemviews/address_book/addresswidget.py b/examples/widgets/itemviews/address_book/addresswidget.py
index 7987ae3cd..cb2f46ea1 100644
--- a/examples/widgets/itemviews/address_book/addresswidget.py
+++ b/examples/widgets/itemviews/address_book/addresswidget.py
@@ -7,7 +7,7 @@ try:
except ImportError:
import pickle
-from PySide6.QtCore import (Qt, Signal, QRegularExpression, QModelIndex,
+from PySide6.QtCore import (Qt, Signal, Slot, QRegularExpression, QModelIndex,
QItemSelection, QSortFilterProxyModel)
from PySide6.QtWidgets import QTabWidget, QMessageBox, QTableView, QAbstractItemView
@@ -35,6 +35,7 @@ class AddressWidget(QTabWidget):
self.setup_tabs()
+ @Slot()
def add_entry(self, name=None, address=None):
""" Add an entry to the addressbook. """
if name is None and address is None:
@@ -83,6 +84,7 @@ class AddressWidget(QTabWidget):
table_view = self.currentWidget()
table_view.resizeRowToContents(ix.row())
+ @Slot()
def edit_entry(self):
""" Edit an entry in the addressbook. """
table_view = self.currentWidget()
@@ -115,6 +117,7 @@ class AddressWidget(QTabWidget):
ix = self._table_model.index(row, 1, QModelIndex())
self._table_model.setData(ix, new_address, Qt.EditRole)
+ @Slot()
def remove_entry(self):
""" Remove an entry from the addressbook. """
table_view = self.currentWidget()
@@ -163,8 +166,9 @@ class AddressWidget(QTabWidget):
proxy_model.setFilterKeyColumn(0) # Filter on the "name" column
proxy_model.sort(0, Qt.AscendingOrder)
- # This prevents an application crash (see: https://www.qtcentre.org/threads/58874-QListView-SelectionModel-selectionChanged-Crash)
- viewselectionmodel = table_view.selectionModel()
+ # This prevents an application crash (see:
+ # https://www.qtcentre.org/threads/58874-QListView-SelectionModel-selectionChanged-Crash) # noqa: E501
+ self.viewselectionmodel = table_view.selectionModel()
table_view.selectionModel().selectionChanged.connect(self.selection_changed)
self.addTab(table_view, group)
diff --git a/examples/widgets/itemviews/address_book/tablemodel.py b/examples/widgets/itemviews/address_book/tablemodel.py
index a0d63bbe2..3c1dbd4cc 100644
--- a/examples/widgets/itemviews/address_book/tablemodel.py
+++ b/examples/widgets/itemviews/address_book/tablemodel.py
@@ -105,5 +105,5 @@ class TableModel(QAbstractTableModel):
"""
if not index.isValid():
return Qt.ItemIsEnabled
- return Qt.ItemFlags(QAbstractTableModel.flags(self, index) |
- Qt.ItemIsEditable)
+ return Qt.ItemFlags(QAbstractTableModel.flags(self, index)
+ | Qt.ItemIsEditable)
diff --git a/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py
index a61a76cb8..a30b0abdf 100644
--- a/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py
+++ b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py
@@ -4,7 +4,7 @@
import sys
from PySide6.QtCore import (QDate, QDateTime, QRegularExpression,
- QSortFilterProxyModel, QTime, Qt)
+ QSortFilterProxyModel, QTime, Qt, Slot)
from PySide6.QtGui import QStandardItemModel
from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox, QGridLayout,
QGroupBox, QHBoxLayout, QLabel, QLineEdit,
@@ -46,11 +46,11 @@ class Window(QWidget):
self._filter_syntax_combo_box = QComboBox()
self._filter_syntax_combo_box.addItem("Regular expression",
- REGULAR_EXPRESSION)
+ REGULAR_EXPRESSION)
self._filter_syntax_combo_box.addItem("Wildcard",
- WILDCARD)
+ WILDCARD)
self._filter_syntax_combo_box.addItem("Fixed string",
- FIXED_STRING)
+ FIXED_STRING)
self._filter_syntax_label = QLabel("Filter &syntax:")
self._filter_syntax_label.setBuddy(self._filter_syntax_combo_box)
@@ -102,6 +102,7 @@ class Window(QWidget):
self._proxy_model.setSourceModel(model)
self._source_view.setModel(model)
+ @Slot()
def filter_reg_exp_changed(self):
syntax_nr = self._filter_syntax_combo_box.currentData()
pattern = self._filter_pattern_line_edit.text()
@@ -117,9 +118,11 @@ class Window(QWidget):
reg_exp.setPatternOptions(options)
self._proxy_model.setFilterRegularExpression(reg_exp)
+ @Slot()
def filter_column_changed(self):
self._proxy_model.setFilterKeyColumn(self._filter_column_combo_box.currentIndex())
+ @Slot()
def sort_changed(self):
if self._sort_case_sensitivity_check_box.isChecked():
case_sensitivity = Qt.CaseSensitive
@@ -144,25 +147,25 @@ def create_mail_model(parent):
model.setHeaderData(2, Qt.Horizontal, "Date")
add_mail(model, "Happy New Year!", "Grace K. <grace@software-inc.com>",
- QDateTime(QDate(2006, 12, 31), QTime(17, 3)))
+ QDateTime(QDate(2006, 12, 31), QTime(17, 3)))
add_mail(model, "Radically new concept", "Grace K. <grace@software-inc.com>",
- QDateTime(QDate(2006, 12, 22), QTime(9, 44)))
+ QDateTime(QDate(2006, 12, 22), QTime(9, 44)))
add_mail(model, "Accounts", "pascale@nospam.com",
- QDateTime(QDate(2006, 12, 31), QTime(12, 50)))
+ QDateTime(QDate(2006, 12, 31), QTime(12, 50)))
add_mail(model, "Expenses", "Joe Bloggs <joe@bloggs.com>",
- QDateTime(QDate(2006, 12, 25), QTime(11, 39)))
+ QDateTime(QDate(2006, 12, 25), QTime(11, 39)))
add_mail(model, "Re: Expenses", "Andy <andy@nospam.com>",
- QDateTime(QDate(2007, 1, 2), QTime(16, 5)))
+ QDateTime(QDate(2007, 1, 2), QTime(16, 5)))
add_mail(model, "Re: Accounts", "Joe Bloggs <joe@bloggs.com>",
- QDateTime(QDate(2007, 1, 3), QTime(14, 18)))
+ QDateTime(QDate(2007, 1, 3), QTime(14, 18)))
add_mail(model, "Re: Accounts", "Andy <andy@nospam.com>",
- QDateTime(QDate(2007, 1, 3), QTime(14, 26)))
+ QDateTime(QDate(2007, 1, 3), QTime(14, 26)))
add_mail(model, "Sports", "Linda Smith <linda.smith@nospam.com>",
- QDateTime(QDate(2007, 1, 5), QTime(11, 33)))
+ QDateTime(QDate(2007, 1, 5), QTime(11, 33)))
add_mail(model, "AW: Sports", "Rolf Newschweinstein <rolfn@nospam.com>",
- QDateTime(QDate(2007, 1, 5), QTime(12, 0)))
+ QDateTime(QDate(2007, 1, 5), QTime(12, 0)))
add_mail(model, "RE: Sports", "Petra Schmidt <petras@nospam.com>",
- QDateTime(QDate(2007, 1, 5), QTime(12, 1)))
+ QDateTime(QDate(2007, 1, 5), QTime(12, 1)))
return model
diff --git a/examples/widgets/itemviews/dirview/dirview.py b/examples/widgets/itemviews/dirview/dirview.py
new file mode 100644
index 000000000..d1be6958e
--- /dev/null
+++ b/examples/widgets/itemviews/dirview/dirview.py
@@ -0,0 +1,59 @@
+# Copyright (C) 2020 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+from argparse import ArgumentParser, RawTextHelpFormatter
+
+from PySide6.QtWidgets import (QApplication, QFileSystemModel,
+ QFileIconProvider, QScroller, QTreeView)
+from PySide6.QtCore import QDir
+
+"""PySide6 port of the widgets/itemviews/dirview example from Qt v6.x"""
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+
+ name = "Dir View"
+ argument_parser = ArgumentParser(description=name,
+ formatter_class=RawTextHelpFormatter)
+ argument_parser.add_argument("--no-custom", "-c", action="store_true",
+ help="Set QFileSystemModel.DontUseCustomDirectoryIcons")
+ argument_parser.add_argument("--no-watch", "-w", action="store_true",
+ help="Set QFileSystemModel.DontWatch")
+ argument_parser.add_argument("directory",
+ help="The directory to start in.",
+ nargs='?', type=str)
+ options = argument_parser.parse_args()
+ root_path = options.directory
+
+ model = QFileSystemModel()
+ icon_provider = QFileIconProvider()
+ model.setIconProvider(icon_provider)
+ model.setRootPath("")
+ if options.no_custom:
+ model.setOption(QFileSystemModel.DontUseCustomDirectoryIcons)
+ if options.no_watch:
+ model.setOption(QFileSystemModel.DontWatchForChanges)
+ tree = QTreeView()
+ tree.setModel(model)
+ if root_path:
+ root_index = model.index(QDir.cleanPath(root_path))
+ if root_index.isValid():
+ tree.setRootIndex(root_index)
+
+ # Demonstrating look and feel features
+ tree.setAnimated(False)
+ tree.setIndentation(20)
+ tree.setSortingEnabled(True)
+ availableSize = tree.screen().availableGeometry().size()
+ tree.resize(availableSize / 2)
+ tree.setColumnWidth(0, tree.width() / 3)
+
+ # Make it flickable on touchscreens
+ QScroller.grabGesture(tree, QScroller.ScrollerGestureType.TouchGesture)
+
+ tree.setWindowTitle(name)
+ tree.show()
+
+ sys.exit(app.exec())
diff --git a/examples/widgets/itemviews/dirview/dirview.pyproject b/examples/widgets/itemviews/dirview/dirview.pyproject
new file mode 100644
index 000000000..9470083c9
--- /dev/null
+++ b/examples/widgets/itemviews/dirview/dirview.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["dirview.py"]
+}
diff --git a/examples/widgets/itemviews/dirview/doc/dirview.rst b/examples/widgets/itemviews/dirview/doc/dirview.rst
new file mode 100644
index 000000000..7044fdf58
--- /dev/null
+++ b/examples/widgets/itemviews/dirview/doc/dirview.rst
@@ -0,0 +1,5 @@
+Dir View Example
+================
+
+The Dir View example shows a tree view of the local file system. It uses the
+QFileSystemModel class to provide file and directory information.
diff --git a/examples/widgets/itemviews/editabletreemodel/mainwindow.py b/examples/widgets/itemviews/editabletreemodel/mainwindow.py
index c6abfa568..1489bf28b 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.py
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.py
@@ -52,7 +52,7 @@ class MainWindow(QMainWindow):
self.insert_child_action.setShortcut("Ctrl+N")
self.insert_child_action.triggered.connect(self.insert_child)
help_menu = menubar.addMenu("&Help")
- about_qt_action = help_menu.addAction("About Qt", qApp.aboutQt)
+ about_qt_action = help_menu.addAction("About Qt", qApp.aboutQt) # noqa: F821
about_qt_action.setShortcut("F1")
self.setWindowTitle("Editable Tree Model")
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.py b/examples/widgets/itemviews/editabletreemodel/treemodel.py
index 58e405c12..a58572fca 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.py
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.py
@@ -2,14 +2,11 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-from PySide6.QtCore import QModelIndex, Qt, QAbstractItemModel, Signal
+from PySide6.QtCore import QModelIndex, Qt, QAbstractItemModel
from treeitem import TreeItem
class TreeModel(QAbstractItemModel):
- # Define signals
- dataChanged = Signal(QModelIndex, QModelIndex, object)
- headerDataChanged = Signal(Qt.Orientation, int, int)
def __init__(self, headers: list, data: str, parent=None):
super().__init__(parent)
@@ -154,9 +151,7 @@ class TreeModel(QAbstractItemModel):
result: bool = self.root_item.set_data(section, value)
if result:
- # todo: Check if emit headerDataChanged signal is correct
- # emit headerDataChanged(orientation, section, section)
- self.headerDataChanged(orientation, section, section)
+ self.headerDataChanged.emit(orientation, section, section)
return result
diff --git a/examples/widgets/itemviews/fetchmore/fetchmore.py b/examples/widgets/itemviews/fetchmore/fetchmore.py
index 08617edad..5150250e0 100644
--- a/examples/widgets/itemviews/fetchmore/fetchmore.py
+++ b/examples/widgets/itemviews/fetchmore/fetchmore.py
@@ -11,9 +11,8 @@ down the list to see the model being populated on demand.
import sys
-from PySide6.QtCore import (QAbstractListModel, QDir, QFileInfo, QLibraryInfo,
+from PySide6.QtCore import (QAbstractListModel, QDir,
QModelIndex, Qt, Signal, Slot)
-from PySide6.QtGui import QPalette
from PySide6.QtWidgets import (QApplication, QFileIconProvider, QListView,
QPlainTextEdit, QSizePolicy, QVBoxLayout,
QWidget)
@@ -50,7 +49,7 @@ class FileListModel(QAbstractListModel):
if role == Qt.BackgroundRole:
batch = row // BATCH_SIZE
- palette = qApp.palette()
+ palette = qApp.palette() # noqa: F821
return palette.base() if batch % 2 == 0 else palette.alternateBase()
if role == Qt.DecorationRole:
@@ -113,7 +112,7 @@ class Window(QWidget):
self.setWindowTitle("Fetch More Example")
- @Slot(str, int, int)
+ @Slot(str, int, int, int)
def update_log(self, path, start, number, total):
native_path = QDir.toNativeSeparators(path)
last = start + number - 1
diff --git a/examples/widgets/itemviews/jsonmodel/jsonmodel.py b/examples/widgets/itemviews/jsonmodel/jsonmodel.py
index c0adfc664..6e614c77f 100644
--- a/examples/widgets/itemviews/jsonmodel/jsonmodel.py
+++ b/examples/widgets/itemviews/jsonmodel/jsonmodel.py
@@ -3,7 +3,7 @@
import json
import sys
-from typing import Any, Iterable, List, Dict, Union
+from typing import Any, List, Dict, Union
from PySide6.QtWidgets import QTreeView, QApplication, QHeaderView
from PySide6.QtCore import QAbstractItemModel, QModelIndex, QObject, Qt, QFileInfo
@@ -182,10 +182,7 @@ class JsonModel(QAbstractItemModel):
item = index.internalPointer()
item.value = str(value)
- if __binding__ in ("PySide", "PyQt4"):
- self.dataChanged.emit(index, index)
- else:
- self.dataChanged.emit(index, index, [Qt.EditRole])
+ self.dataChanged.emit(index, index, [Qt.EditRole])
return True
diff --git a/examples/widgets/itemviews/spinboxdelegate/doc/spinboxdelegate.rst b/examples/widgets/itemviews/spinboxdelegate/doc/spinboxdelegate.rst
new file mode 100644
index 000000000..12e505207
--- /dev/null
+++ b/examples/widgets/itemviews/spinboxdelegate/doc/spinboxdelegate.rst
@@ -0,0 +1,5 @@
+SpinBox Delegate Example
+=========================
+
+A simple example that shows how a view can use a custom delegate to edit
+data obtained from a model.
diff --git a/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py
new file mode 100644
index 000000000..577f0faa5
--- /dev/null
+++ b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py
@@ -0,0 +1,79 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtWidgets import (QApplication, QStyledItemDelegate, QSpinBox,
+ QTableView)
+from PySide6.QtGui import QStandardItemModel, Qt
+from PySide6.QtCore import QModelIndex
+
+"""PySide6 port of the widgets/itemviews/spinboxdelegate from Qt v6.x"""
+
+
+#! [0]
+class SpinBoxDelegate(QStyledItemDelegate):
+ """A delegate that allows the user to change integer values from the model
+ using a spin box widget. """
+
+#! [0]
+ def __init__(self, parent=None):
+ super().__init__(parent)
+#! [0]
+
+#! [1]
+ def createEditor(self, parent, option, index):
+ editor = QSpinBox(parent)
+ editor.setFrame(False)
+ editor.setMinimum(0)
+ editor.setMaximum(100)
+ return editor
+#! [1]
+
+#! [2]
+ def setEditorData(self, editor, index):
+ value = index.model().data(index, Qt.EditRole)
+ editor.setValue(value)
+#! [2]
+
+#! [3]
+ def setModelData(self, editor, model, index):
+ editor.interpretText()
+ value = editor.value()
+ model.setData(index, value, Qt.EditRole)
+#! [3]
+
+#! [4]
+ def updateEditorGeometry(self, editor, option, index):
+ editor.setGeometry(option.rect)
+#! [4]
+
+
+#! [main0]
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+
+ model = QStandardItemModel(4, 2)
+ tableView = QTableView()
+ tableView.setModel(model)
+
+ delegate = SpinBoxDelegate()
+ tableView.setItemDelegate(delegate)
+#! [main0]
+
+ tableView.horizontalHeader().setStretchLastSection(True)
+
+#! [main1]
+ for row in range(4):
+ for column in range(2):
+ index = model.index(row, column, QModelIndex())
+ value = (row + 1) * (column + 1)
+ model.setData(index, value)
+#! [main1] //# [main2]
+#! [main2]
+
+#! [main3]
+ tableView.setWindowTitle("Spin Box Delegate")
+ tableView.show()
+ sys.exit(app.exec())
+#! [main3]
diff --git a/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pyproject b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pyproject
new file mode 100644
index 000000000..70616905c
--- /dev/null
+++ b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["spinboxdelegate.py"]
+}
diff --git a/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.png b/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.png
new file mode 100644
index 000000000..ae7dde24b
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.png
Binary files differ
diff --git a/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.rst b/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.rst
new file mode 100644
index 000000000..c0839b232
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/doc/spreadsheet.rst
@@ -0,0 +1,10 @@
+Spreadsheet example
+===================
+
+The Spreadsheet example shows how a table view can be used to create a simple
+spreadsheet application. Custom delegates are used to render different types of
+data in distinctive colors.
+
+.. image:: spreadsheet.png
+ :width: 400
+ :alt: Spreadsheet screenshot
diff --git a/examples/widgets/itemviews/spreadsheet/main.py b/examples/widgets/itemviews/spreadsheet/main.py
new file mode 100644
index 000000000..0ecc5ec23
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/main.py
@@ -0,0 +1,19 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtGui import QPixmap
+from PySide6.QtWidgets import QApplication, QLayout
+
+from spreadsheet import SpreadSheet
+
+if __name__ == "__main__":
+ app = QApplication()
+
+ sheet = SpreadSheet(10, 6)
+ sheet.setWindowIcon(QPixmap(":/images/interview.png"))
+ sheet.show()
+ sheet.layout().setSizeConstraint(QLayout.SetFixedSize)
+
+ sys.exit(app.exec())
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.py b/examples/widgets/itemviews/spreadsheet/spreadsheet.py
new file mode 100644
index 000000000..82ebe5ebb
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.py
@@ -0,0 +1,544 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from PySide6.QtCore import QPoint, Qt, QCoreApplication, Slot
+from PySide6.QtGui import QAction, QBrush, QPixmap, QColor, QPainter
+from PySide6.QtWidgets import (QColorDialog, QComboBox, QDialog, QFontDialog,
+ QGroupBox, QHBoxLayout, QMainWindow, QLabel,
+ QLineEdit, QMessageBox, QPushButton, QToolBar,
+ QTableWidgetItem, QTableWidget, QVBoxLayout, QWidget)
+
+from spreadsheetdelegate import SpreadSheetDelegate
+from spreadsheetitem import SpreadSheetItem
+
+from typing import Optional
+from numbers import Number
+
+
+class SpreadSheet(QMainWindow):
+ def __init__(self, rows: Number, cols: Number, parent: Optional[QWidget] = None) -> None:
+ super().__init__(parent)
+
+ self._tool_bar = QToolBar(self)
+ self._color_action = QAction()
+ self._font_action = QAction()
+ self._first_separator = QAction()
+ self._cell_sum_action = QAction()
+ self._cell_add_action = QAction()
+ self._cell_sub_action = QAction()
+ self._cell_mul_action = QAction()
+ self._cell_div_action = QAction()
+ self._second_separator = QAction()
+ self._clear_action = QAction()
+ self._about_spreadsheet = QAction()
+ self._exit_action = QAction()
+
+ # self._print_action = QAction()
+
+ self._cell_label = QLabel(self._tool_bar)
+ self._table = QTableWidget(rows, cols, self)
+ self._formula_input = QLineEdit(self)
+
+ self.addToolBar(self._tool_bar)
+
+ self._cell_label.setMinimumSize(80, 0)
+
+ self._tool_bar.addWidget(self._cell_label)
+ self._tool_bar.addWidget(self._formula_input)
+
+ self._table.setSizeAdjustPolicy(QTableWidget.SizeAdjustPolicy.AdjustToContents)
+ for c in range(cols):
+ character = chr(ord('A') + c)
+ self._table.setHorizontalHeaderItem(c, QTableWidgetItem(character))
+
+ self._table.setItemPrototype(self._table.item(rows - 1, cols - 1))
+ self._table.setItemDelegate(SpreadSheetDelegate())
+
+ self.create_actions()
+ self.update_color(None)
+ self.setup_menu_bar()
+ self.setup_contents()
+ self.setup_context_menu()
+ self.setCentralWidget(self._table)
+
+ self.statusBar()
+ self._table.currentItemChanged.connect(self.update_status)
+ self._table.currentItemChanged.connect(self.update_color)
+ self._table.currentItemChanged.connect(self.update_line_edit)
+ self._table.itemChanged.connect(self.update_status)
+ self._formula_input.returnPressed.connect(self.return_pressed)
+ self._table.itemChanged.connect(self.update_line_edit)
+
+ self.setWindowTitle("Spreadsheet")
+
+ def create_actions(self) -> None:
+ self._cell_sum_action = QAction("Sum", self)
+ self._cell_sum_action.triggered.connect(self.action_sum)
+
+ self._cell_add_action = QAction("&Add", self)
+ self._cell_add_action.setShortcut(Qt.CTRL | Qt.Key_Plus)
+ self._cell_add_action.triggered.connect(self.action_add)
+
+ self._cell_sub_action = QAction("&Subtract", self)
+ self._cell_sub_action.setShortcut(Qt.CTRL | Qt.Key_Minus)
+ self._cell_sub_action.triggered.connect(self.action_subtract)
+
+ self._cell_mul_action = QAction("&Multiply", self)
+ self._cell_mul_action.setShortcut(Qt.CTRL | Qt.Key_multiply)
+ self._cell_mul_action.triggered.connect(self.action_multiply)
+
+ self._cell_div_action = QAction("&Divide", self)
+ self._cell_div_action.setShortcut(Qt.CTRL | Qt.Key_division)
+ self._cell_div_action.triggered.connect(self.action_divide)
+
+ self._font_action = QAction("Font...", self)
+ self._font_action.setShortcut(Qt.CTRL | Qt.Key_F)
+ self._font_action.triggered.connect(self.select_font)
+
+ self._color_action = QAction(QPixmap(16, 16), "Background &Color...", self)
+ self._color_action.triggered.connect(self.select_color)
+
+ self._clear_action = QAction("Clear", self)
+ self._clear_action.setShortcut(Qt.Key_Delete)
+ self._clear_action.triggered.connect(self.clear)
+
+ self._about_spreadsheet = QAction("About Spreadsheet", self)
+ self._about_spreadsheet.triggered.connect(self.show_about)
+
+ self._exit_action = QAction("E&xit", self)
+ self._exit_action.triggered.connect(QCoreApplication.quit)
+
+ self._first_separator = QAction(self)
+ self._first_separator.setSeparator(True)
+
+ self._second_separator = QAction(self)
+ self._second_separator.setSeparator(True)
+
+ def setup_menu_bar(self) -> None:
+ file_menu = self.menuBar().addMenu("&File")
+ # file_menu.addAction(self._print_action)
+ file_menu.addAction(self._exit_action)
+
+ cell_menu = self.menuBar().addMenu("&Cell")
+ cell_menu.addAction(self._cell_add_action)
+ cell_menu.addAction(self._cell_sub_action)
+ cell_menu.addAction(self._cell_mul_action)
+ cell_menu.addAction(self._cell_div_action)
+ cell_menu.addAction(self._cell_sum_action)
+ cell_menu.addSeparator()
+ cell_menu.addAction(self._color_action)
+ cell_menu.addAction(self._font_action)
+
+ self.menuBar().addSeparator()
+
+ about_menu = self.menuBar().addMenu("&Help")
+ about_menu.addAction(self._about_spreadsheet)
+
+ @Slot(QTableWidgetItem)
+ def update_status(self, item: QTableWidgetItem) -> None:
+ if item and item == self._table.currentItem():
+ self.statusBar().showMessage(str(item.data(Qt.StatusTipRole)), 1000)
+ self._cell_label.setText(
+ "Cell: ({})".format(
+ SpreadSheetItem.encode_pos(self._table.row(item), self._table.column(item))
+ )
+ )
+
+ @Slot(QTableWidgetItem)
+ def update_color(self, item: QTableWidgetItem) -> None:
+ pix = QPixmap(16, 16)
+ col = QColor()
+ if item:
+ col = item.background().color()
+ if not col.isValid():
+ col = self.palette().base().color()
+
+ pt = QPainter(pix)
+ pt.fillRect(0, 0, 16, 16, col)
+
+ lighter = col.lighter()
+ pt.setPen(lighter)
+ light_frame = [QPoint(0, 15), QPoint(0, 0), QPoint(15, 0)]
+ pt.drawPolyline(light_frame)
+
+ pt.setPen(col.darker())
+ darkFrame = [QPoint(1, 15), QPoint(15, 15), QPoint(15, 1)]
+ pt.drawPolyline(darkFrame)
+
+ pt.end()
+
+ self._color_action.setIcon(pix)
+
+ @Slot(QTableWidgetItem)
+ def update_line_edit(self, item: QTableWidgetItem) -> None:
+ if item != self._table.currentItem():
+ return
+ if item:
+ self._formula_input.setText(str(item.data(Qt.EditRole)))
+ else:
+ self._formula_input.clear()
+
+ @Slot()
+ def return_pressed(self) -> None:
+ text = self._formula_input.text()
+ row = self._table.currentRow()
+ col = self._table.currentColumn()
+ item = self._table.item(row, col)
+ if not item:
+ self._table.setItem(row, col, SpreadSheetItem(text))
+ else:
+ item.setData(Qt.EditRole, text)
+ self._table.viewport().update()
+
+ @Slot()
+ def select_color(self) -> None:
+ item = self._table.currentItem()
+ col = item.background().color() if item else self._table.palette().base().color()
+ col = QColorDialog.getColor(col, self)
+ if not col.isValid():
+ return
+
+ selected = self._table.selectedItems()
+ if not selected:
+ return
+
+ for i in selected:
+ if i:
+ i.setBackground(col)
+
+ self.update_color(self._table.currentItem())
+
+ @Slot()
+ def select_font(self) -> None:
+ selected = self._table.selectedItems()
+ if not selected:
+ return
+
+ ok = False
+ fnt = QFontDialog.getFont(ok, self.font(), self)
+
+ if not ok:
+ return
+ for i in selected:
+ if i:
+ i.setFont(fnt)
+
+ def run_input_dialog(self, title: str, c1Text: str, c2Text: str, opText: str,
+ outText: str, cell1: str, cell2: str, outCell: str) -> bool:
+ rows, cols = [], []
+ for c in range(self._table.columnCount()):
+ cols.append(chr(ord('A') + c))
+ for r in range(self._table.rowCount()):
+ rows.append(str(1 + r))
+
+ add_dialog = QDialog(self)
+ add_dialog.setWindowTitle(title)
+
+ group = QGroupBox(title, add_dialog)
+ group.setMinimumSize(250, 100)
+
+ cell1_label = QLabel(c1Text, group)
+ cell1_row_input = QComboBox(group)
+ c1_row, c1_col = SpreadSheetItem.decode_pos(cell1)
+ cell1_row_input.addItems(rows)
+ cell1_row_input.setCurrentIndex(c1_row)
+
+ cell1_col_input = QComboBox(group)
+ cell1_col_input.addItems(cols)
+ cell1_col_input.setCurrentIndex(c1_col)
+
+ operator_label = QLabel(opText, group)
+ operator_label.setAlignment(Qt.AlignHCenter)
+
+ cell2_label = QLabel(c2Text, group)
+ cell2_row_input = QComboBox(group)
+ c2_row, c2_col = SpreadSheetItem.decode_pos(cell2)
+ cell2_row_input.addItems(rows)
+ cell2_row_input.setCurrentIndex(c2_row)
+ cell2_col_input = QComboBox(group)
+ cell2_col_input.addItems(cols)
+ cell2_col_input.setCurrentIndex(c2_col)
+
+ equals_label = QLabel("=", group)
+ equals_label.setAlignment(Qt.AlignHCenter)
+
+ out_label = QLabel(outText, group)
+ out_row_input = QComboBox(group)
+ out_row, out_col = SpreadSheetItem.decode_pos(outCell)
+ out_row_input.addItems(rows)
+ out_row_input.setCurrentIndex(out_row)
+ out_col_input = QComboBox(group)
+ out_col_input.addItems(cols)
+ out_col_input.setCurrentIndex(out_col)
+
+ cancel_button = QPushButton("Cancel", add_dialog)
+ cancel_button.clicked.connect(add_dialog.reject)
+
+ ok_button = QPushButton("OK", add_dialog)
+ ok_button.setDefault(True)
+ ok_button.clicked.connect(add_dialog.accept)
+
+ buttons_layout = QHBoxLayout()
+ buttons_layout.addStretch(1)
+ buttons_layout.addWidget(ok_button)
+ buttons_layout.addSpacing(10)
+ buttons_layout.addWidget(cancel_button)
+
+ dialog_layout = QVBoxLayout(add_dialog)
+ dialog_layout.addWidget(group)
+ dialog_layout.addStretch(1)
+ dialog_layout.addItem(buttons_layout)
+
+ cell1_layout = QHBoxLayout()
+ cell1_layout.addWidget(cell1_label)
+ cell1_layout.addSpacing(10)
+ cell1_layout.addWidget(cell1_col_input)
+ cell1_layout.addSpacing(10)
+ cell1_layout.addWidget(cell1_row_input)
+
+ cell2_layout = QHBoxLayout()
+ cell2_layout.addWidget(cell2_label)
+ cell2_layout.addSpacing(10)
+ cell2_layout.addWidget(cell2_col_input)
+ cell2_layout.addSpacing(10)
+ cell2_layout.addWidget(cell2_row_input)
+
+ out_layout = QHBoxLayout()
+ out_layout.addWidget(out_label)
+ out_layout.addSpacing(10)
+ out_layout.addWidget(out_col_input)
+ out_layout.addSpacing(10)
+ out_layout.addWidget(out_row_input)
+
+ v_layout = QVBoxLayout(group)
+ v_layout.addItem(cell1_layout)
+ v_layout.addWidget(operator_label)
+ v_layout.addItem(cell2_layout)
+ v_layout.addWidget(equals_label)
+ v_layout.addStretch(1)
+ v_layout.addItem(out_layout)
+
+ if add_dialog.exec():
+ cell1 = cell1_col_input.currentText() + cell1_row_input.currentText()
+ cell2 = cell2_col_input.currentText() + cell2_row_input.currentText()
+ outCell = out_col_input.currentText() + out_row_input.currentText()
+ return True
+
+ return False
+
+ @Slot()
+ def action_sum(self) -> None:
+ row_first = row_last = row_cur = 0
+ col_first = col_last = col_cur = 0
+
+ selected = self._table.selectedItems()
+
+ if selected is not None:
+ first = selected[0]
+ last = selected[-1]
+ row_first = self._table.row(first)
+ row_last = self._table.row(last)
+ col_first = self._table.column(first)
+ col_last = self._table.column(last)
+
+ current = self._table.currentItem()
+
+ if current:
+ row_cur = self._table.row(current)
+ col_cur = self._table.column(current)
+
+ cell1 = SpreadSheetItem.encode_pos(row_first, col_first)
+ cell2 = SpreadSheetItem.encode_pos(row_last, col_last)
+ out = SpreadSheetItem.encode_pos(row_cur, col_cur)
+
+ if self.run_input_dialog(
+ "Sum cells", "First cell:", "Last cell:",
+ f"{(chr(0x03a3))}", "Output to:",
+ cell1, cell2, out
+ ):
+ row, col = SpreadSheetItem.decode_pos(out)
+ self._table.item(row, col).setText(f"sum {cell1} {cell2}")
+
+ def action_math_helper(self, title: str, op: str) -> None:
+ cell1 = "C1"
+ cell2 = "C2"
+ out = "C3"
+
+ current = self._table.currentItem()
+ if current:
+ out = SpreadSheetItem.encode_pos(self._table.currentRow(), self._table.currentColumn())
+
+ if self.run_input_dialog(title, "Cell 1", "Cell 2", op, "Output to:", cell1, cell2, out):
+ row, col = SpreadSheetItem.decode_pos(out)
+ self._table.item(row, col).setText(f"{op} {cell1} {cell2}")
+
+ @Slot()
+ def action_add(self) -> None:
+ self.action_math_helper("Addition", "+")
+
+ @Slot()
+ def action_subtract(self) -> None:
+ self.action_math_helper("Subtraction", "-")
+
+ @Slot()
+ def action_multiply(self) -> None:
+ self.action_math_helper("Multiplication", "*")
+
+ @Slot()
+ def action_divide(self) -> None:
+ self.action_math_helper("Division", "/")
+
+ @Slot()
+ def clear(self) -> None:
+ selected_items = self._table.selectedItems()
+ for item in selected_items:
+ item.setText("")
+
+ def setup_context_menu(self) -> None:
+ self.addAction(self._cell_add_action)
+ self.addAction(self._cell_sub_action)
+ self.addAction(self._cell_mul_action)
+ self.addAction(self._cell_div_action)
+ self.addAction(self._cell_sum_action)
+ self.addAction(self._first_separator)
+ self.addAction(self._color_action)
+ self.addAction(self._font_action)
+ self.addAction(self._second_separator)
+ self.addAction(self._clear_action)
+ self.setContextMenuPolicy(Qt.ActionsContextMenu)
+
+ def setup_contents(self) -> None:
+ title_background = QBrush(Qt.lightGray)
+ title_font = self._table.font()
+ title_font.setBold(True)
+
+ # column 0
+ self._table.setItem(0, 0, SpreadSheetItem("Item"))
+ self._table.item(0, 0).setBackground(title_background)
+ self._table.item(0, 0).setToolTip(
+ "This column shows the purchased item/service"
+ )
+ self._table.item(0, 0).setFont(title_font)
+
+ self._table.setItem(1, 0, SpreadSheetItem("AirportBus"))
+ self._table.setItem(2, 0, SpreadSheetItem("Flight (Munich)"))
+ self._table.setItem(3, 0, SpreadSheetItem("Lunch"))
+ self._table.setItem(4, 0, SpreadSheetItem("Flight (LA)"))
+ self._table.setItem(5, 0, SpreadSheetItem("Taxi"))
+ self._table.setItem(6, 0, SpreadSheetItem("Dinner"))
+ self._table.setItem(7, 0, SpreadSheetItem("Hotel"))
+ self._table.setItem(8, 0, SpreadSheetItem("Flight (Oslo)"))
+ self._table.setItem(9, 0, SpreadSheetItem("Total:"))
+
+ self._table.item(9, 0).setFont(title_font)
+ self._table.item(9, 0).setBackground(title_background)
+
+ # column 1
+ self._table.setItem(0, 1, SpreadSheetItem("Date"))
+ self._table.item(0, 1).setBackground(title_background)
+ self._table.item(0, 1).setToolTip(
+ "This column shows the purchase date, double click to change"
+ )
+ self._table.item(0, 1).setFont(title_font)
+
+ self._table.setItem(1, 1, SpreadSheetItem("15/6/2006"))
+ self._table.setItem(2, 1, SpreadSheetItem("15/6/2006"))
+ self._table.setItem(3, 1, SpreadSheetItem("15/6/2006"))
+ self._table.setItem(4, 1, SpreadSheetItem("21/5/2006"))
+ self._table.setItem(5, 1, SpreadSheetItem("16/6/2006"))
+ self._table.setItem(6, 1, SpreadSheetItem("16/6/2006"))
+ self._table.setItem(7, 1, SpreadSheetItem("16/6/2006"))
+ self._table.setItem(8, 1, SpreadSheetItem("18/6/2006"))
+
+ self._table.setItem(9, 1, SpreadSheetItem())
+ self._table.item(9, 1).setBackground(title_background)
+
+ # column 2
+ self._table.setItem(0, 2, SpreadSheetItem("Price"))
+ self._table.item(0, 2).setBackground(title_background)
+ self._table.item(0, 2).setToolTip("This column shows the price of the purchase")
+ self._table.item(0, 2).setFont(title_font)
+
+ self._table.setItem(1, 2, SpreadSheetItem("150"))
+ self._table.setItem(2, 2, SpreadSheetItem("2350"))
+ self._table.setItem(3, 2, SpreadSheetItem("-14"))
+ self._table.setItem(4, 2, SpreadSheetItem("980"))
+ self._table.setItem(5, 2, SpreadSheetItem("5"))
+ self._table.setItem(6, 2, SpreadSheetItem("120"))
+ self._table.setItem(7, 2, SpreadSheetItem("300"))
+ self._table.setItem(8, 2, SpreadSheetItem("1240"))
+
+ self._table.setItem(9, 2, SpreadSheetItem())
+ self._table.item(9, 2).setBackground(Qt.lightGray)
+
+ # column 3
+ self._table.setItem(0, 3, SpreadSheetItem("Currency"))
+ self._table.item(0, 3).setBackground(title_background)
+ self._table.item(0, 3).setToolTip("This column shows the currency")
+ self._table.item(0, 3).setFont(title_font)
+
+ self._table.setItem(1, 3, SpreadSheetItem("NOK"))
+ self._table.setItem(2, 3, SpreadSheetItem("NOK"))
+ self._table.setItem(3, 3, SpreadSheetItem("EUR"))
+ self._table.setItem(4, 3, SpreadSheetItem("EUR"))
+ self._table.setItem(5, 3, SpreadSheetItem("USD"))
+ self._table.setItem(6, 3, SpreadSheetItem("USD"))
+ self._table.setItem(7, 3, SpreadSheetItem("USD"))
+ self._table.setItem(8, 3, SpreadSheetItem("USD"))
+
+ self._table.setItem(9, 3, SpreadSheetItem())
+ self._table.item(9, 3).setBackground(Qt.lightGray)
+
+ # column 4
+ self._table.setItem(0, 4, SpreadSheetItem("Ex. Rate"))
+ self._table.item(0, 4).setBackground(title_background)
+ self._table.item(0, 4).setToolTip("This column shows the exchange rate to NOK")
+ self._table.item(0, 4).setFont(title_font)
+
+ self._table.setItem(1, 4, SpreadSheetItem("1"))
+ self._table.setItem(2, 4, SpreadSheetItem("1"))
+ self._table.setItem(3, 4, SpreadSheetItem("8"))
+ self._table.setItem(4, 4, SpreadSheetItem("8"))
+ self._table.setItem(5, 4, SpreadSheetItem("7"))
+ self._table.setItem(6, 4, SpreadSheetItem("7"))
+ self._table.setItem(7, 4, SpreadSheetItem("7"))
+ self._table.setItem(8, 4, SpreadSheetItem("7"))
+
+ self._table.setItem(9, 4, SpreadSheetItem())
+ self._table.item(9, 4).setBackground(title_background)
+
+ # column 5
+ self._table.setItem(0, 5, SpreadSheetItem("NOK"))
+ self._table.item(0, 5).setBackground(title_background)
+ self._table.item(0, 5).setToolTip("This column shows the expenses in NOK")
+ self._table.item(0, 5).setFont(title_font)
+
+ self._table.setItem(1, 5, SpreadSheetItem("* C2 E2"))
+ self._table.setItem(2, 5, SpreadSheetItem("* C3 E3"))
+ self._table.setItem(3, 5, SpreadSheetItem("* C4 E4"))
+ self._table.setItem(4, 5, SpreadSheetItem("* C5 E5"))
+ self._table.setItem(5, 5, SpreadSheetItem("* C6 E6"))
+ self._table.setItem(6, 5, SpreadSheetItem("* C7 E7"))
+ self._table.setItem(7, 5, SpreadSheetItem("* C8 E8"))
+ self._table.setItem(8, 5, SpreadSheetItem("* C9 E9"))
+
+ self._table.setItem(9, 5, SpreadSheetItem("sum F2 F9"))
+ self._table.item(9, 5).setBackground(title_background)
+
+ @Slot()
+ def show_about(self) -> None:
+ html_text = (
+ "<HTML>"
+ "<p><b>This demo shows use of <c>QTableWidget</c> with custom handling for"
+ " individual cells.</b></p>"
+ "<p>Using a customized table item we make it possible to have dynamic"
+ " output in different cells. The content that is implemented for this"
+ " particular demo is:"
+ "<ul>"
+ "<li>Adding two cells.</li>"
+ "<li>Subtracting one cell from another.</li>"
+ "<li>Multiplying two cells.</li>"
+ "<li>Dividing one cell with another.</li>"
+ "<li>Summing the contents of an arbitrary number of cells.</li>"
+ "</HTML>")
+ QMessageBox.about(self, "About Spreadsheet", html_text)
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.py b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.py
new file mode 100644
index 000000000..57aba6f47
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from PySide6.QtCore import (QAbstractItemModel, QDate, QModelIndex, QObject,
+ QStringListModel, Qt, Slot)
+from PySide6.QtWidgets import (QCompleter, QDateTimeEdit, QLineEdit,
+ QStyleOptionViewItem, QStyledItemDelegate, QWidget)
+
+from typing import Optional
+
+
+class SpreadSheetDelegate(QStyledItemDelegate):
+ def __init__(self, parent: Optional[QObject] = None) -> None:
+ super().__init__(parent)
+
+ def create_editor(self, parent: QWidget,
+ option: QStyleOptionViewItem,
+ index: QModelIndex) -> QWidget:
+ if index.column() == 1:
+ editor = QDateTimeEdit(parent)
+ editor.setDisplayFormat("dd/M/yyyy")
+ editor.setCalendarPopup(True)
+ return editor
+
+ editor = QLineEdit(parent)
+
+ # create a completer with the strings in the column as model
+ allStrings = QStringListModel()
+ for i in range(1, index.model().rowCount()):
+ strItem = str(index.model().data(index.sibling(i, index.column()), Qt.EditRole))
+
+ if not allStrings.contains(strItem):
+ allStrings.append(strItem)
+
+ autoComplete = QCompleter(allStrings)
+ editor.setCompleter(autoComplete)
+ editor.editingFinished.connect(SpreadSheetDelegate.commit_and_close_editor)
+ return editor
+
+ @Slot()
+ def commit_and_close_editor(self) -> None:
+ editor = self.sender()
+ self.commitData.emit(editor)
+ self.closeEditor.emit(editor)
+
+ def set_editor_data(self, editor: QWidget, index: QModelIndex) -> None:
+ edit = QLineEdit(editor)
+ if edit:
+ edit.setText(str(index.model().data(index, Qt.EditRole)))
+ return
+
+ dateEditor = QDateTimeEdit(editor)
+ if dateEditor:
+ dateEditor.setDate(
+ QDate.fromString(
+ str(index.model().data(index, Qt.EditRole)), "d/M/yyyy"))
+
+ def set_model_data(self, editor: QWidget,
+ model: QAbstractItemModel, index: QModelIndex) -> None:
+ edit = QLineEdit(editor)
+ if edit:
+ model.setData(index, edit.text())
+ return
+
+ dateEditor = QDateTimeEdit(editor)
+ if dateEditor:
+ model.setData(index, dateEditor.date().toString("dd/M/yyyy"))
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetitem.py b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.py
new file mode 100644
index 000000000..dc70da883
--- /dev/null
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.py
@@ -0,0 +1,122 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from typing import Any, Tuple
+from PySide6.QtCore import QMetaType, Qt
+from PySide6.QtWidgets import QTableWidget, QTableWidgetItem
+
+
+class SpreadSheetItem(QTableWidgetItem):
+ is_resolving = False
+
+ def __init_subclass__(cls) -> None:
+ return super().__init_subclass__()
+
+ def data(self, role: int) -> Any:
+ if role == Qt.EditRole or role == Qt.StatusTipRole:
+ return self.formula()
+
+ if role == Qt.DisplayRole:
+ return self.display()
+
+ t = str(self.display())
+
+ if role == Qt.ForegroundRole:
+ try:
+ number = int(t)
+ color = Qt.red if number < 0 else Qt.blue
+ except ValueError:
+ color = Qt.black
+ return color
+
+ if role == Qt.TextAlignmentRole:
+ if t and (t[0].isdigit() or t[0] == '-'):
+ return int(Qt.AlignRight | Qt.AlignVCenter)
+
+ return super().data(role)
+
+ def setData(self, role: int, value: Any) -> None:
+ super().setData(role, value)
+ if self.tableWidget():
+ self.tableWidget().viewport().update()
+
+ def display(self) -> QMetaType.Type.QVariant:
+ # avoid circular dependencies
+ if self.is_resolving:
+ return QMetaType.Type.QVariant
+
+ self.is_resolving = True
+ result = self.compute_formula(self.formula(), self.tableWidget(), self)
+ self.is_resolving = False
+ return result
+
+ def formula(self) -> None:
+ return str(super().data(Qt.DisplayRole))
+
+ def compute_formula(self, formula: str, widget: QTableWidget, this) -> QMetaType.Type.QVariant:
+ # check if the string is actually a formula or not
+ list_ = formula.split(' ')
+ if not list_ or not widget:
+ return formula # it is a normal string
+
+ op = list_[0].lower() if list_[0] else ""
+
+ first_row = -1
+ first_col = -1
+ second_row = -1
+ second_col = -1
+
+ if len(list_) > 1:
+ SpreadSheetItem.decode_pos(list_[1])
+
+ if len(list_) > 2:
+ SpreadSheetItem.decode_pos(list_[2])
+
+ start = widget.item(first_row, first_col)
+ end = widget.item(second_row, second_col)
+
+ first_val = int(start.text()) if start else 0
+ second_val = int(end.text()) if start else 0
+
+ if op == "sum":
+ sum = 0
+ for r in range(first_row, second_row + 1):
+ for c in range(first_col, second_col + 1):
+ table_item = widget.item(r, c)
+ if table_item and table_item != this:
+ sum += int(table_item.text())
+
+ result = sum
+ elif op == "+":
+ result = first_val + second_val
+ elif op == "-":
+ result = first_val - second_val
+ elif op == "*":
+ result = first_val * second_val
+ elif op == "/":
+ if second_val == 0:
+ result = "nan"
+ else:
+ result = first_val / second_val
+ elif op == "=":
+ if start:
+ result = start.text()
+ else:
+ result = formula
+
+ return result
+
+ def decode_pos(pos: str) -> Tuple[int, int]:
+ if (not pos):
+ col = -1
+ row = -1
+ else:
+ col = ord(pos[0].encode("latin1")) - ord('A')
+ try:
+ row = int(pos[1:]) - 1
+ except ValueError:
+ row = -1
+ return row, col
+
+ def encode_pos(row: int, col: int) -> str:
+ return str(chr(col + ord('A'))) + str(row + 1)
diff --git a/examples/widgets/itemviews/stardelegate/stardelegate.py b/examples/widgets/itemviews/stardelegate/stardelegate.py
index 87bf1ff48..973eb14f6 100644
--- a/examples/widgets/itemviews/stardelegate/stardelegate.py
+++ b/examples/widgets/itemviews/stardelegate/stardelegate.py
@@ -111,15 +111,15 @@ if __name__ == "__main__":
# Create and populate the tableWidget
table_widget = QTableWidget(4, 4)
table_widget.setItemDelegate(StarDelegate())
- table_widget.setEditTriggers(QAbstractItemView.DoubleClicked |
- QAbstractItemView.SelectedClicked)
+ table_widget.setEditTriggers(QAbstractItemView.DoubleClicked
+ | QAbstractItemView.SelectedClicked)
table_widget.setSelectionBehavior(QAbstractItemView.SelectRows)
table_widget.setHorizontalHeaderLabels(["Title", "Genre", "Artist", "Rating"])
- data = [ ["Mass in B-Minor", "Baroque", "J.S. Bach", 5],
- ["Three More Foxes", "Jazz", "Maynard Ferguson", 4],
- ["Sex Bomb", "Pop", "Tom Jones", 3],
- ["Barbie Girl", "Pop", "Aqua", 5] ]
+ data = [["Mass in B-Minor", "Baroque", "J.S. Bach", 5],
+ ["Three More Foxes", "Jazz", "Maynard Ferguson", 4],
+ ["Sex Bomb", "Pop", "Tom Jones", 3],
+ ["Barbie Girl", "Pop", "Aqua", 5]]
for r in range(len(data)):
table_widget.setItem(r, 0, QTableWidgetItem(data[r][0]))
diff --git a/examples/widgets/itemviews/stardelegate/stareditor.py b/examples/widgets/itemviews/stardelegate/stareditor.py
index 1b44164a8..296afa950 100644
--- a/examples/widgets/itemviews/stardelegate/stareditor.py
+++ b/examples/widgets/itemviews/stardelegate/stareditor.py
@@ -55,8 +55,7 @@ class StarEditor(QWidget):
""" Calculate which star the user's mouse cursor is currently
hovering over.
"""
- star = (x / (self.star_rating.sizeHint().width() /
- self.star_rating.MAX_STAR_COUNT)) + 1
+ star = (x / (self.star_rating.sizeHint().width() / self.star_rating.MAX_STAR_COUNT)) + 1
if (star <= 0) or (star > self.star_rating.MAX_STAR_COUNT):
return -1
diff --git a/examples/widgets/itemviews/stardelegate/starrating.py b/examples/widgets/itemviews/stardelegate/starrating.py
index 4d49f7405..28dbacd6f 100644
--- a/examples/widgets/itemviews/stardelegate/starrating.py
+++ b/examples/widgets/itemviews/stardelegate/starrating.py
@@ -23,13 +23,13 @@ class StarRating(object):
self._star_polygon.append(QPointF(1.0, 0.5))
for i in range(1, 5):
self._star_polygon.append(QPointF(0.5 + 0.5 * cos(0.8 * i * pi),
- 0.5 + 0.5 * sin(0.8 * i * pi)))
+ 0.5 + 0.5 * sin(0.8 * i * pi)))
# Create the diamond shape we'll show in the editor
self._diamond_polygon = QPolygonF()
diamond_points = [QPointF(0.4, 0.5), QPointF(0.5, 0.4),
- QPointF(0.6, 0.5), QPointF(0.5, 0.6),
- QPointF(0.4, 0.5)]
+ QPointF(0.6, 0.5), QPointF(0.5, 0.6),
+ QPointF(0.4, 0.5)]
self._diamond_polygon.append(diamond_points)
def sizeHint(self):
diff --git a/examples/widgets/layouts/basiclayouts/basiclayouts.py b/examples/widgets/layouts/basiclayouts/basiclayouts.py
index ab8e77311..827cb7850 100644
--- a/examples/widgets/layouts/basiclayouts/basiclayouts.py
+++ b/examples/widgets/layouts/basiclayouts/basiclayouts.py
@@ -6,12 +6,11 @@
import sys
-from PySide6.QtCore import Qt
from PySide6.QtWidgets import (QApplication, QComboBox, QDialog,
QDialogButtonBox, QGridLayout, QGroupBox,
QFormLayout, QHBoxLayout, QLabel, QLineEdit,
QMenu, QMenuBar, QPushButton, QSpinBox,
- QTextEdit, QVBoxLayout, QWidget)
+ QTextEdit, QVBoxLayout)
class Dialog(QDialog):
@@ -28,7 +27,7 @@ class Dialog(QDialog):
big_editor = QTextEdit()
big_editor.setPlainText("This widget takes up all the remaining space "
- "in the top-level layout.")
+ "in the top-level layout.")
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
@@ -76,8 +75,7 @@ class Dialog(QDialog):
layout.addWidget(line_edit, i + 1, 1)
self._small_editor = QTextEdit()
- self._small_editor.setPlainText("This widget takes up about two thirds "
- "of the grid layout.")
+ self._small_editor.setPlainText("This widget takes up about two thirds of the grid layout.")
layout.addWidget(self._small_editor, 0, 2, 4, 1)
diff --git a/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py b/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py
index a9eec159a..c9dfcc730 100644
--- a/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py
+++ b/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py
@@ -50,7 +50,7 @@ class Dialog(QDialog):
self._main_layout.setSizeConstraint(QLayout.SetNoConstraint)
self.setMinimumSize(0, 0)
- orientation = Qt.Orientation(int(self._buttons_orientation_combo_box.itemData(index)))
+ orientation = Qt.Orientation(self._buttons_orientation_combo_box.itemData(index))
if orientation == self._button_box.orientation():
return
@@ -74,8 +74,8 @@ class Dialog(QDialog):
def show_help(self):
QMessageBox.information(self, "Dynamic Layouts Help",
- "This example shows how to change layouts "
- "dynamically.")
+ "This example shows how to change layouts "
+ "dynamically.")
def create_rotable_group_box(self):
self._rotable_group_box = QGroupBox("Rotable Widgets")
@@ -102,7 +102,8 @@ class Dialog(QDialog):
buttons_orientation_combo_box = QComboBox()
buttons_orientation_combo_box.addItem("Horizontal", Qt.Horizontal)
buttons_orientation_combo_box.addItem("Vertical", Qt.Vertical)
- buttons_orientation_combo_box.currentIndexChanged[int].connect(self.buttons_orientation_changed)
+ buttons_orientation_combo_box.currentIndexChanged[int].connect(
+ self.buttons_orientation_changed)
self._buttons_orientation_combo_box = buttons_orientation_combo_box
@@ -117,7 +118,8 @@ class Dialog(QDialog):
close_button = self._button_box.addButton(QDialogButtonBox.Close)
help_button = self._button_box.addButton(QDialogButtonBox.Help)
- rotate_widgets_button = self._button_box.addButton("Rotate &Widgets", QDialogButtonBox.ActionRole)
+ rotate_widgets_button = self._button_box.addButton(
+ "Rotate &Widgets", QDialogButtonBox.ActionRole)
rotate_widgets_button.clicked.connect(self.rotate_widgets)
close_button.clicked.connect(self.close)
diff --git a/examples/widgets/linguist/doc/linguist.rst b/examples/widgets/linguist/doc/linguist.rst
new file mode 100644
index 000000000..24a49a617
--- /dev/null
+++ b/examples/widgets/linguist/doc/linguist.rst
@@ -0,0 +1,7 @@
+.. _qt-linguist-example:
+
+Qt Linguist Example
+===================
+
+This example demonstrates the use of Qt Linguist and related tools for translating
+applications as described in :ref:`translations`.
diff --git a/examples/widgets/linguist/linguist.qrc b/examples/widgets/linguist/linguist.qrc
index 2b08ae577..6ca287c20 100644
--- a/examples/widgets/linguist/linguist.qrc
+++ b/examples/widgets/linguist/linguist.qrc
@@ -1,5 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>translations/example_de.qm</file>
+<qresource prefix="translations">
+ <file>example_de.qm</file>
</qresource>
</RCC>
diff --git a/examples/widgets/linguist/main.py b/examples/widgets/linguist/main.py
index e71779f77..e4212e801 100644
--- a/examples/widgets/linguist/main.py
+++ b/examples/widgets/linguist/main.py
@@ -1,16 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-from pathlib import Path
import sys
from PySide6.QtCore import (QItemSelection, QLibraryInfo, QLocale, QTranslator,
- Qt, Slot)
+ Slot)
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QListWidget,
- QMainWindow, QWidget)
+ QMainWindow)
-import linguist_rc
+import linguist_rc # noqa: F401
class Window(QMainWindow):
@@ -22,7 +21,7 @@ class Window(QMainWindow):
quit_action.triggered.connect(self.close)
help_menu = self.menuBar().addMenu(self.tr("&Help"))
about_qt_action = help_menu.addAction(self.tr("About Qt"))
- about_qt_action.triggered.connect(qApp.aboutQt)
+ about_qt_action.triggered.connect(qApp.aboutQt) # noqa: F821
self._list_widget = QListWidget()
self._list_widget.setSelectionMode(QAbstractItemView.MultiSelection)
@@ -42,7 +41,7 @@ class Window(QMainWindow):
if __name__ == '__main__':
app = QApplication(sys.argv)
- path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
+ path = QLibraryInfo.path(QLibraryInfo.TranslationsPath)
translator = QTranslator(app)
if translator.load(QLocale.system(), 'qtbase', '_', path):
app.installTranslator(translator)
diff --git a/examples/widgets/mainwindows/application/application.py b/examples/widgets/mainwindows/application/application.py
index 79c3b0f03..f69eade2e 100644
--- a/examples/widgets/mainwindows/application/application.py
+++ b/examples/widgets/mainwindows/application/application.py
@@ -6,12 +6,12 @@ from argparse import ArgumentParser, RawTextHelpFormatter
import sys
from PySide6.QtCore import (QByteArray, QFile, QFileInfo, QSaveFile, QSettings,
- QTextStream, Qt)
+ QTextStream, Qt, Slot)
from PySide6.QtGui import QAction, QIcon, QKeySequence
from PySide6.QtWidgets import (QApplication, QFileDialog, QMainWindow,
- QMessageBox, QTextEdit, QWidget)
+ QMessageBox, QTextEdit)
-import application_rc
+import application_rc # noqa: F401
class MainWindow(QMainWindow):
@@ -42,23 +42,27 @@ class MainWindow(QMainWindow):
else:
event.ignore()
+ @Slot()
def new_file(self):
if self.maybe_save():
self._text_edit.clear()
self.set_current_file('')
+ @Slot()
def open(self):
if self.maybe_save():
fileName, filtr = QFileDialog.getOpenFileName(self)
if fileName:
self.load_file(fileName)
+ @Slot()
def save(self):
if self._cur_file:
return self.save_file(self._cur_file)
return self.save_as()
+ @Slot()
def save_as(self):
fileName, filtr = QFileDialog.getSaveFileName(self)
if fileName:
@@ -66,62 +70,67 @@ class MainWindow(QMainWindow):
return False
+ @Slot()
def about(self):
QMessageBox.about(self, "About Application",
- "The <b>Application</b> example demonstrates how to write "
- "modern GUI applications using Qt, with a menu bar, "
- "toolbars, and a status bar.")
+ "The <b>Application</b> example demonstrates how to write "
+ "modern GUI applications using Qt, with a menu bar, "
+ "toolbars, and a status bar.")
+ @Slot()
def document_was_modified(self):
self.setWindowModified(self._text_edit.document().isModified())
def create_actions(self):
- icon = QIcon.fromTheme("document-new", QIcon(':/images/new.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentNew, QIcon(':/images/new.png'))
self._new_act = QAction(icon, "&New", self, shortcut=QKeySequence.New,
- statusTip="Create a new file", triggered=self.new_file)
+ statusTip="Create a new file", triggered=self.new_file)
- icon = QIcon.fromTheme("document-open", QIcon(':/images/open.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentOpen, QIcon(':/images/open.png'))
self._open_act = QAction(icon, "&Open...", self,
- shortcut=QKeySequence.Open, statusTip="Open an existing file",
- triggered=self.open)
+ shortcut=QKeySequence.Open, statusTip="Open an existing file",
+ triggered=self.open)
- icon = QIcon.fromTheme("document-save", QIcon(':/images/save.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentSave, QIcon(':/images/save.png'))
self._save_act = QAction(icon, "&Save", self,
- shortcut=QKeySequence.Save,
- statusTip="Save the document to disk", triggered=self.save)
+ shortcut=QKeySequence.Save,
+ statusTip="Save the document to disk", triggered=self.save)
self._save_as_act = QAction("Save &As...", self,
- shortcut=QKeySequence.SaveAs,
- statusTip="Save the document under a new name",
- triggered=self.save_as)
+ shortcut=QKeySequence.SaveAs,
+ statusTip="Save the document under a new name",
+ triggered=self.save_as)
- self._exit_act = QAction("E&xit", self, shortcut="Ctrl+Q",
- statusTip="Exit the application", triggered=self.close)
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit)
+ self._exit_act = QAction(icon, "E&xit", self, shortcut="Ctrl+Q",
+ statusTip="Exit the application", triggered=self.close)
- icon = QIcon.fromTheme("edit-cut", QIcon(':/images/cut.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCut, QIcon(':/images/cut.png'))
self._cut_act = QAction(icon, "Cu&t", self, shortcut=QKeySequence.Cut,
- statusTip="Cut the current selection's contents to the clipboard",
- triggered=self._text_edit.cut)
+ statusTip="Cut the current selection's contents to the clipboard",
+ triggered=self._text_edit.cut)
- icon = QIcon.fromTheme("edit-copy", QIcon(':/images/copy.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCopy, QIcon(':/images/copy.png'))
self._copy_act = QAction(icon, "&Copy",
- self, shortcut=QKeySequence.Copy,
- statusTip="Copy the current selection's contents to the clipboard",
- triggered=self._text_edit.copy)
+ self, shortcut=QKeySequence.Copy,
+ statusTip="Copy the current selection's contents to the clipboard",
+ triggered=self._text_edit.copy)
- icon = QIcon.fromTheme("edit-paste", QIcon(':/images/paste.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditPaste, QIcon(':/images/paste.png'))
self._paste_act = QAction(icon, "&Paste",
- self, shortcut=QKeySequence.Paste,
- statusTip="Paste the clipboard's contents into the current selection",
- triggered=self._text_edit.paste)
+ self, shortcut=QKeySequence.Paste,
+ statusTip="Paste the clipboard's contents into the current "
+ "selection",
+ triggered=self._text_edit.paste)
- self._about_act = QAction("&About", self,
- statusTip="Show the application's About box",
- triggered=self.about)
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.HelpAbout)
+ self._about_act = QAction(icon, "&About", self,
+ statusTip="Show the application's About box",
+ triggered=self.about)
self._about_qt_act = QAction("About &Qt", self,
- statusTip="Show the Qt library's About box",
- triggered=qApp.aboutQt)
+ statusTip="Show the Qt library's About box",
+ triggered=qApp.aboutQt) # noqa: F821
self._cut_act.setEnabled(False)
self._copy_act.setEnabled(False)
@@ -175,10 +184,9 @@ class MainWindow(QMainWindow):
def maybe_save(self):
if self._text_edit.document().isModified():
ret = QMessageBox.warning(self, "Application",
- "The document has been modified.\nDo you want to save "
- "your changes?",
- QMessageBox.Save | QMessageBox.Discard |
- QMessageBox.Cancel)
+ "The document has been modified.\nDo you want to save "
+ "your changes?",
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
if ret == QMessageBox.Save:
return self.save()
elif ret == QMessageBox.Cancel:
@@ -189,8 +197,7 @@ class MainWindow(QMainWindow):
file = QFile(fileName)
if not file.open(QFile.ReadOnly | QFile.Text):
reason = file.errorString()
- QMessageBox.warning(self, "Application",
- f"Cannot read file {fileName}:\n{reason}.")
+ QMessageBox.warning(self, "Application", f"Cannot read file {fileName}:\n{reason}.")
return
inf = QTextStream(file)
diff --git a/examples/widgets/mainwindows/application/application.pyproject b/examples/widgets/mainwindows/application/application.pyproject
index 0e0413982..a9365ed1a 100644
--- a/examples/widgets/mainwindows/application/application.pyproject
+++ b/examples/widgets/mainwindows/application/application.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["application.qrc", "application.py", "application_rc.py"]
+ "files": ["application.qrc", "application.py"]
}
diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
index f8d5ffe26..83487ee58 100644
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
+++ b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
@@ -2,18 +2,20 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-"""PySide6 port of the widgets/mainwindows/dockwidgets example from Qt v5.x, originating from PyQt"""
+"""PySide6 port of the widgets/mainwindows/dockwidgets example from Qt v5.x,
+ originating from PyQt"""
import sys
from PySide6.QtCore import QDate, QFile, Qt, QTextStream
from PySide6.QtGui import (QAction, QFont, QIcon, QKeySequence,
- QTextCharFormat, QTextCursor, QTextTableFormat)
+ QTextCharFormat, QTextCursor, QTextTableFormat)
from PySide6.QtPrintSupport import QPrintDialog, QPrinter
from PySide6.QtWidgets import (QApplication, QDialog, QDockWidget,
- QFileDialog, QListWidget, QMainWindow, QMessageBox, QTextEdit)
+ QFileDialog, QListWidget, QMainWindow,
+ QMessageBox, QTextEdit)
-import dockwidgets_rc
+import dockwidgets_rc # noqa: F401
class MainWindow(QMainWindow):
@@ -62,8 +64,7 @@ class MainWindow(QMainWindow):
cursor.insertBlock()
cursor.insertText("Some Country")
cursor.setPosition(top_frame.lastPosition())
- cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"),
- text_format)
+ cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"), text_format)
cursor.insertBlock()
cursor.insertBlock()
cursor.insertText("Dear ", text_format)
@@ -103,7 +104,7 @@ class MainWindow(QMainWindow):
if not file.open(QFile.WriteOnly | QFile.Text):
reason = file.errorString()
QMessageBox.warning(self, "Dock Widgets",
- "Cannot write file {filename}:\n{reason}.")
+ f"Cannot write file {filename}:\n{reason}.")
return
out = QTextStream(file)
@@ -143,8 +144,8 @@ class MainWindow(QMainWindow):
if cursor.isNull():
return
cursor.beginEditBlock()
- cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
- 2)
+ cursor.movePosition(QTextCursor.PreviousBlock,
+ QTextCursor.MoveAnchor, 2)
cursor.insertBlock()
cursor.insertText(paragraph)
cursor.insertBlock()
@@ -152,43 +153,44 @@ class MainWindow(QMainWindow):
def about(self):
QMessageBox.about(self, "About Dock Widgets",
- "The <b>Dock Widgets</b> example demonstrates how to use "
- "Qt's dock widgets. You can enter your own text, click a "
- "customer to add a customer name and address, and click "
- "standard paragraphs to add them.")
+ "The <b>Dock Widgets</b> example demonstrates how to use "
+ "Qt's dock widgets. You can enter your own text, click a "
+ "customer to add a customer name and address, and click "
+ "standard paragraphs to add them.")
def create_actions(self):
icon = QIcon.fromTheme('document-new', QIcon(':/images/new.png'))
self._new_letter_act = QAction(icon, "&New Letter",
- self, shortcut=QKeySequence.New,
- statusTip="Create a new form letter", triggered=self.new_letter)
+ self, shortcut=QKeySequence.New,
+ statusTip="Create a new form letter",
+ triggered=self.new_letter)
icon = QIcon.fromTheme('document-save', QIcon(':/images/save.png'))
self._save_act = QAction(icon, "&Save...", self,
- shortcut=QKeySequence.Save,
- statusTip="Save the current form letter", triggered=self.save)
+ shortcut=QKeySequence.Save,
+ statusTip="Save the current form letter", triggered=self.save)
icon = QIcon.fromTheme('document-print', QIcon(':/images/print.png'))
self._print_act = QAction(icon, "&Print...", self,
- shortcut=QKeySequence.Print,
- statusTip="Print the current form letter",
- triggered=self.print_)
+ shortcut=QKeySequence.Print,
+ statusTip="Print the current form letter",
+ triggered=self.print_)
icon = QIcon.fromTheme('edit-undo', QIcon(':/images/undo.png'))
self._undo_act = QAction(icon, "&Undo", self,
- shortcut=QKeySequence.Undo,
- statusTip="Undo the last editing action", triggered=self.undo)
+ shortcut=QKeySequence.Undo,
+ statusTip="Undo the last editing action", triggered=self.undo)
self._quit_act = QAction("&Quit", self, shortcut="Ctrl+Q",
- statusTip="Quit the application", triggered=self.close)
+ statusTip="Quit the application", triggered=self.close)
self._about_act = QAction("&About", self,
- statusTip="Show the application's About box",
- triggered=self.about)
+ statusTip="Show the application's About box",
+ triggered=self.about)
self._about_qt_act = QAction("About &Qt", self,
- statusTip="Show the Qt library's About box",
- triggered=QApplication.instance().aboutQt)
+ statusTip="Show the Qt library's About box",
+ triggered=QApplication.instance().aboutQt)
def create_menus(self):
self._file_menu = self.menuBar().addMenu("&File")
@@ -241,21 +243,21 @@ class MainWindow(QMainWindow):
self._paragraphs_list.addItems((
"Thank you for your payment which we have received today.",
"Your order has been dispatched and should be with you within "
- "28 days.",
+ "28 days.",
"We have dispatched those items that were in stock. The rest of "
- "your order will be dispatched once all the remaining items "
- "have arrived at our warehouse. No additional shipping "
- "charges will be made.",
+ "your order will be dispatched once all the remaining items "
+ "have arrived at our warehouse. No additional shipping "
+ "charges will be made.",
"You made a small overpayment (less than $5) which we will keep "
- "on account for you, or return at your request.",
+ "on account for you, or return at your request.",
"You made a small underpayment (less than $1), but we have sent "
- "your order anyway. We'll add this underpayment to your next "
- "bill.",
+ "your order anyway. We'll add this underpayment to your next "
+ "bill.",
"Unfortunately you did not send enough money. Please remit an "
- "additional $. Your order will be dispatched as soon as the "
- "complete amount has been received.",
+ "additional $. Your order will be dispatched as soon as the "
+ "complete amount has been received.",
"You made an overpayment (more than $5). Do you wish to buy more "
- "items, or should we return the excess to you?"))
+ "items, or should we return the excess to you?"))
dock.setWidget(self._paragraphs_list)
self.addDockWidget(Qt.RightDockWidgetArea, dock)
self._view_menu.addAction(dock.toggleViewAction())
diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pyproject b/examples/widgets/mainwindows/dockwidgets/dockwidgets.pyproject
index 2df11468e..9abbf7485 100644
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pyproject
+++ b/examples/widgets/mainwindows/dockwidgets/dockwidgets.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["dockwidgets.qrc", "dockwidgets.py", "dockwidgets_rc.py"]
+ "files": ["dockwidgets.qrc", "dockwidgets.py"]
}
diff --git a/examples/widgets/mainwindows/mdi/images/copy.png b/examples/widgets/mainwindows/mdi/images/copy.png
deleted file mode 100644
index 2aeb28288..000000000
--- a/examples/widgets/mainwindows/mdi/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/cut.png b/examples/widgets/mainwindows/mdi/images/cut.png
deleted file mode 100644
index 54638e938..000000000
--- a/examples/widgets/mainwindows/mdi/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/new.png b/examples/widgets/mainwindows/mdi/images/new.png
deleted file mode 100644
index 12131b010..000000000
--- a/examples/widgets/mainwindows/mdi/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/open.png b/examples/widgets/mainwindows/mdi/images/open.png
deleted file mode 100644
index 45fa2883a..000000000
--- a/examples/widgets/mainwindows/mdi/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/paste.png b/examples/widgets/mainwindows/mdi/images/paste.png
deleted file mode 100644
index c14425cad..000000000
--- a/examples/widgets/mainwindows/mdi/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/save.png b/examples/widgets/mainwindows/mdi/images/save.png
deleted file mode 100644
index daba865fa..000000000
--- a/examples/widgets/mainwindows/mdi/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/mdi.py b/examples/widgets/mainwindows/mdi/mdi.py
index af402ffe8..c1fa01b8c 100644
--- a/examples/widgets/mainwindows/mdi/mdi.py
+++ b/examples/widgets/mainwindows/mdi/mdi.py
@@ -8,13 +8,13 @@ from argparse import ArgumentParser, RawTextHelpFormatter
from functools import partial
import sys
-from PySide6.QtCore import (QByteArray, QFile, QFileInfo, QPoint, QSettings,
- QSaveFile, QSize, QTextStream, Qt)
+from PySide6.QtCore import (QByteArray, QFile, QFileInfo, QSettings,
+ QSaveFile, QTextStream, Qt, Slot)
from PySide6.QtGui import QAction, QIcon, QKeySequence
from PySide6.QtWidgets import (QApplication, QFileDialog, QMainWindow,
- QMdiArea, QMessageBox, QTextEdit, QWidget)
+ QMdiArea, QMessageBox, QTextEdit)
-import mdi_rc
+import PySide6.QtExampleIcons # noqa: F401
class MdiChild(QTextEdit):
@@ -106,7 +106,7 @@ class MdiChild(QTextEdit):
f = self.user_friendly_current_file()
message = f"'{f}' has been modified.\nDo you want to save your changes?"
ret = QMessageBox.warning(self, "MDI", message,
- QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
if ret == QMessageBox.Save:
return self.save()
@@ -156,11 +156,13 @@ class MainWindow(QMainWindow):
self.write_settings()
event.accept()
+ @Slot()
def new_file(self):
child = self.create_mdi_child()
child.new_file()
child.show()
+ @Slot()
def open(self):
file_name, _ = QFileDialog.getOpenFileName(self)
if file_name:
@@ -178,31 +180,38 @@ class MainWindow(QMainWindow):
else:
child.close()
+ @Slot()
def save(self):
if self.active_mdi_child() and self.active_mdi_child().save():
self.statusBar().showMessage("File saved", 2000)
+ @Slot()
def save_as(self):
if self.active_mdi_child() and self.active_mdi_child().save_as():
self.statusBar().showMessage("File saved", 2000)
+ @Slot()
def cut(self):
if self.active_mdi_child():
self.active_mdi_child().cut()
+ @Slot()
def copy(self):
if self.active_mdi_child():
self.active_mdi_child().copy()
+ @Slot()
def paste(self):
if self.active_mdi_child():
self.active_mdi_child().paste()
+ @Slot()
def about(self):
QMessageBox.about(self, "About MDI",
- "The <b>MDI</b> example demonstrates how to write multiple "
- "document interface applications using Qt.")
+ "The <b>MDI</b> example demonstrates how to write multiple "
+ "document interface applications using Qt.")
+ @Slot()
def update_menus(self):
has_mdi_child = (self.active_mdi_child() is not None)
self._save_act.setEnabled(has_mdi_child)
@@ -216,11 +225,12 @@ class MainWindow(QMainWindow):
self._previous_act.setEnabled(has_mdi_child)
self._separator_act.setVisible(has_mdi_child)
- has_selection = (self.active_mdi_child() is not None and
- self.active_mdi_child().textCursor().hasSelection())
+ has_selection = (self.active_mdi_child() is not None
+ and self.active_mdi_child().textCursor().hasSelection())
self._cut_act.setEnabled(has_selection)
self._copy_act.setEnabled(has_selection)
+ @Slot()
def update_window_menu(self):
self._window_menu.clear()
self._window_menu.addAction(self._close_act)
@@ -261,82 +271,85 @@ class MainWindow(QMainWindow):
def create_actions(self):
- icon = QIcon.fromTheme("document-new", QIcon(':/images/new.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentNew)
self._new_act = QAction(icon, "&New", self,
- shortcut=QKeySequence.New, statusTip="Create a new file",
- triggered=self.new_file)
+ shortcut=QKeySequence.New, statusTip="Create a new file",
+ triggered=self.new_file)
- icon = QIcon.fromTheme("document-open", QIcon(':/images/open.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentOpen)
self._open_act = QAction(icon, "&Open...", self,
- shortcut=QKeySequence.Open, statusTip="Open an existing file",
- triggered=self.open)
+ shortcut=QKeySequence.Open, statusTip="Open an existing file",
+ triggered=self.open)
- icon = QIcon.fromTheme("document-save", QIcon(':/images/save.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentSave)
self._save_act = QAction(icon, "&Save", self,
- shortcut=QKeySequence.Save,
- statusTip="Save the document to disk", triggered=self.save)
+ shortcut=QKeySequence.Save,
+ statusTip="Save the document to disk", triggered=self.save)
self._save_as_act = QAction("Save &As...", self,
- shortcut=QKeySequence.SaveAs,
- statusTip="Save the document under a new name",
- triggered=self.save_as)
+ shortcut=QKeySequence.SaveAs,
+ statusTip="Save the document under a new name",
+ triggered=self.save_as)
- self._exit_act = QAction("E&xit", self, shortcut=QKeySequence.Quit,
- statusTip="Exit the application",
- triggered=QApplication.instance().closeAllWindows)
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit)
+ self._exit_act = QAction(icon, "E&xit", self, shortcut=QKeySequence.Quit,
+ statusTip="Exit the application",
+ triggered=QApplication.instance().closeAllWindows)
- icon = QIcon.fromTheme("edit-cut", QIcon(':/images/cut.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCut)
self._cut_act = QAction(icon, "Cu&t", self,
- shortcut=QKeySequence.Cut,
- statusTip="Cut the current selection's contents to the clipboard",
- triggered=self.cut)
+ shortcut=QKeySequence.Cut,
+ statusTip="Cut the current selection's contents to the clipboard",
+ triggered=self.cut)
- icon = QIcon.fromTheme("edit-copy", QIcon(':/images/copy.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCopy)
self._copy_act = QAction(icon, "&Copy", self,
- shortcut=QKeySequence.Copy,
- statusTip="Copy the current selection's contents to the clipboard",
- triggered=self.copy)
+ shortcut=QKeySequence.Copy,
+ statusTip="Copy the current selection's contents to the clipboard",
+ triggered=self.copy)
- icon = QIcon.fromTheme("edit-paste", QIcon(':/images/paste.png'))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditPaste)
self._paste_act = QAction(icon, "&Paste", self,
- shortcut=QKeySequence.Paste,
- statusTip="Paste the clipboard's contents into the current selection",
- triggered=self.paste)
+ shortcut=QKeySequence.Paste,
+ statusTip="Paste the clipboard's contents into the current "
+ "selection",
+ triggered=self.paste)
self._close_act = QAction("Cl&ose", self,
- statusTip="Close the active window",
- triggered=self._mdi_area.closeActiveSubWindow)
+ statusTip="Close the active window",
+ triggered=self._mdi_area.closeActiveSubWindow)
self._close_all_act = QAction("Close &All", self,
- statusTip="Close all the windows",
- triggered=self._mdi_area.closeAllSubWindows)
+ statusTip="Close all the windows",
+ triggered=self._mdi_area.closeAllSubWindows)
self._tile_act = QAction("&Tile", self, statusTip="Tile the windows",
- triggered=self._mdi_area.tileSubWindows)
+ triggered=self._mdi_area.tileSubWindows)
self._cascade_act = QAction("&Cascade", self,
- statusTip="Cascade the windows",
- triggered=self._mdi_area.cascadeSubWindows)
+ statusTip="Cascade the windows",
+ triggered=self._mdi_area.cascadeSubWindows)
self._next_act = QAction("Ne&xt", self, shortcut=QKeySequence.NextChild,
- statusTip="Move the focus to the next window",
- triggered=self._mdi_area.activateNextSubWindow)
+ statusTip="Move the focus to the next window",
+ triggered=self._mdi_area.activateNextSubWindow)
self._previous_act = QAction("Pre&vious", self,
- shortcut=QKeySequence.PreviousChild,
- statusTip="Move the focus to the previous window",
- triggered=self._mdi_area.activatePreviousSubWindow)
+ shortcut=QKeySequence.PreviousChild,
+ statusTip="Move the focus to the previous window",
+ triggered=self._mdi_area.activatePreviousSubWindow)
self._separator_act = QAction(self)
self._separator_act.setSeparator(True)
- self._about_act = QAction("&About", self,
- statusTip="Show the application's About box",
- triggered=self.about)
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.HelpAbout)
+ self._about_act = QAction(icon, "&About", self,
+ statusTip="Show the application's About box",
+ triggered=self.about)
self._about_qt_act = QAction("About &Qt", self,
- statusTip="Show the Qt library's About box",
- triggered=QApplication.instance().aboutQt)
+ statusTip="Show the Qt library's About box",
+ triggered=QApplication.instance().aboutQt)
def create_menus(self):
self._file_menu = self.menuBar().addMenu("&File")
@@ -402,6 +415,7 @@ class MainWindow(QMainWindow):
return window
return None
+ @Slot()
def switch_layout_direction(self):
if self.layoutDirection() == Qt.LeftToRight:
QApplication.setLayoutDirection(Qt.RightToLeft)
@@ -421,6 +435,11 @@ if __name__ == '__main__':
options = argument_parser.parse_args()
app = QApplication(sys.argv)
+
+ icon_paths = QIcon.themeSearchPaths()
+ QIcon.setThemeSearchPaths(icon_paths + [":/qt-project.org/icons"])
+ QIcon.setFallbackThemeName("example_icons")
+
main_win = MainWindow()
for f in options.files:
main_win.load(f)
diff --git a/examples/widgets/mainwindows/mdi/mdi.pyproject b/examples/widgets/mainwindows/mdi/mdi.pyproject
index 7df26fd77..0272873a7 100644
--- a/examples/widgets/mainwindows/mdi/mdi.pyproject
+++ b/examples/widgets/mainwindows/mdi/mdi.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["mdi_rc.py", "mdi.py", "mdi.qrc"]
+ "files": ["mdi.py"]
}
diff --git a/examples/widgets/mainwindows/mdi/mdi.qrc b/examples/widgets/mainwindows/mdi/mdi.qrc
deleted file mode 100644
index 0a776fab4..000000000
--- a/examples/widgets/mainwindows/mdi/mdi.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/mainwindows/mdi/mdi_rc.py b/examples/widgets/mainwindows/mdi/mdi_rc.py
deleted file mode 100644
index bc8336765..000000000
--- a/examples/widgets/mainwindows/mdi/mdi_rc.py
+++ /dev/null
@@ -1,608 +0,0 @@
-# Resource object code (Python 3)
-# Created by: object code
-# Created by: The Resource Compiler for Qt version 6.2.2
-# WARNING! All changes made in this file will be lost!
-
-from PySide6 import QtCore
-
-qt_resource_data = b"\
-\x00\x00\x08\x19\
-\x89\
-PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
-\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\
-\x00\x00\x00\x04gAMA\x00\x00\xd6\xd8\xd4OX2\
-\x00\x00\x00\x19tEXtSoftware\
-\x00Adobe ImageRead\
-yq\xc9e<\x00\x00\x07\xabIDATX\xc3\xad\
-W[P\x93g\x1a\xf6\xca\xce\xec\xcc\xf6b/\xbc\xd9\
-\xe9\xce\xecn\xbd\xda\xd9\x9b\xb5\xce\xba;{\xb0\xad\xcc\
-z\xb1\xce\xce:\xb3vTpu\xdb\xe2\x81\xd6\xb6T\
-\x04\xbb\xa5 m\xc1\x82\x06\x08\x07QB\x80\x80\x80\x02\
-!\x81\x10\x92@H\x10s$!gr\x80\x04B \
-\x9c\x09G\xb5Tx\xf6\xfb~\x13\x160X\x8b}g\
-\x9e\xf9/\x92\xfc\xcf\xfb>\xcf\xfb\xbe\xdf\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cb\
-\xafE\xb9v\x002g`\xf5\xc2\xa7\x97\xa9\xdc\xf7\x08\
-\xd2\xa9\xdc;\xf8\x03\xf3\xc2\xf1\x13\x82\xca\x1c\xee\x9dP\
-\x0b9\x94\xb8\x0d\xc2\xc8\x16\xa3\x17\x87\xc3/\x22\xf7\x0e\
-\xff\xdam\x8a\xdda\x99\xd5\x1b\xb6\xd8k\xbb^2\xbe\
-/\x89\xff\x01f\xb9_\xfc\x11\x80=\xcf\x00\x00\x00\x00\
-IEND\xaeB`\x82\
-\x00\x00\x03T\
-\x89\
-PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
-\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\
-\x00\x00\x00\x04gAMA\x00\x00\xd6\xd8\xd4OX2\
-\x00\x00\x00\x19tEXtSoftware\
-\x00Adobe ImageRead\
-yq\xc9e<\x00\x00\x02\xe6IDATX\xc3\xd5\
-\x97\xcdN\x13a\x14\x86\xeb5\x94\x95{q\xe1\xd2\xc4\
-\xe0\x05\xb8\xe2\x0e\x5c\xb8\xf4\x02\x5c\xb10\xea\x05\x18\x96\
-&bX\xb8\xb0\x91X \xd1\x9d\xbf\x89\xa4\x14\xb1R\
-\xa4HE\x94\xfe\xd0\x02C\xff\xa6\x9d\x19\xa6e\x80\xe3\
-y{\xfa\x85QJ\x82\xc9!\x86I\xde\x9c3\xa7\xf3\
-\xcd\xfb\x9c\xf3M\x9bN\x84\x88\x22\xffS\x91s\x01\xc0\
-\xc7\xd5\x90n\xff\xa5\xfb\xac\xc7==d\x0d\xa9\x02\xf0\
-12<<\xbcj4::\xba\x19V<\x1e\xaf&\
-\x93\xc9V:\x9dv\x13\x89Dk`` \xcdkn\
-h\x02\xa48\xd2\xe1\xe1q\x99\xba\xef\xb7\xc9\xb2,\xda\
-\xdf\xdf'\x86\xf1x\xcd\x18\xeb\x8a\x1a@?\xf3\xb0\x1c\
-\xc7\xa5Lf\xb9\x0b\x14\x04\x01\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xa9\xa1\x08\x80\xfd\xfcV\x12s3\x01\
-\x085\x18B\xe8\xda|\x8e)\xa8N\x00[\x00\x03\xc8\
-\x98g6\x04\x002\xe6\x85\xde\xf8\x17\x0b\xfc,\xd8\x8a\
-\x00\x18g:O\xb4T\x14#\x98\x02\x00\x02\x0c>\xfb\
-\xc5S(\xf0C\xb8fI\xf7k\xf9R\x87\xd7\xbeT\
-\x01\xc8U\x8f\xbaN\xadK\x0e\x90\xaf\x85\xde\xb7\xc2\x92\
-=O\xa6\xb3\xde\xa3\xb1q\xeb\xda\xd0\xf5\x15\x98\xb3n\
-\xa9\x00l4\xa4k\x18\xff\xe0\x11\x7fZ\x17S\xd4\x13\
-\x0bYo\xe4\xee\xbd\xe2\xa5\xc1\xcbK|m\x8cu\x87\
-5\xa8\xfa\xb7\x1c\xdde\xd9<\x8f\x1f\x19\xfe\x9e\xcf\x1e\
-7\xbd\xc9\xbax&oF\x00h\xf2\xff\x81\x99\x94\x9e\
-\xe9?\xbf\x19\x01B\xd3\xf4\xfc\xbd\x9c\x9e\xa5~\x03Q\
-l%\xa1\x92\x95\x0aw\x00\x00\x00\x00IEND\xae\
-B`\x82\
-\x00\x00\x05:\
-\x89\
-PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
-\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\
-\x00\x00\x00\x04gAMA\x00\x00\xd6\xd8\xd4OX2\
-\x00\x00\x00\x19tEXtSoftware\
-\x00Adobe ImageRead\
-yq\xc9e<\x00\x00\x04\xccIDATX\xc3\xb5\
-\x97]L[e\x1c\xc6wo\xbc\xd9\xe5\x12I q\
-\xd7&\xe3N\x13\xb8p\xd1\x85D\xbdP\xe3\x10\x18\xe5\
-+.&J\x04'\x86\xaa\x8b\x99\xe0\xd0\xa2l\x19\x86\
-9\x17\xdc\x1a\x16\x98\x80@l\xa6C\xca +\x83\x1e\
-(\xcc\xda\xd1\x96\xd2\xd2J{\xfa\x01\xa5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5c\xbc\
->,/\xc0\xc6\xc6\x06\xf4z\xfdc@}}\xfdP\
-2\x88\xd0F\x1cf\x9b\x0b\x82\xc1\x88\xa9\x19\x13\xac\x0e\
-\x11\x97\xbadn\x80\x00\xa6\xd8:\xd8~E\x22\x11\x94\
-+*0\xae\x13@\xe7\x04mW\xda\xaa4\xbe|S\
-\xe65@f:\x9d\x0e\xc3\xc3\xc3\xe8e\xf5\xf7\xf7\xf7\
-C\xab\xd5\xa2\xaa\xba\x06cw\xf5\x90\x0e*w\x90\xed\
-\x04\xb6\x0e\xda\xbbe\x06\xa0y\xb7\xdb\xed\x18\x1a\x1aB\
-gg'zzz8PIi\x19ni\xf5\x10\xd7\
-\x00o\x08\xb0\xf9\x00g\x00\xb8\xd0%3\xc0\xd6\xd6\x16\
-\xdf\x09\x81@\x00\xa2(\xc2\xef\xf7cmm\x0d\xa7\x14\
-\x95\xd0\xfc\xae\xe7\xa9\xc9|\xc1\x0b\x98=@\x9b\xdc\x00\
-\xdbA677\xf9v\xa4V\x14\x15\xd5\xe8\xfbU\xe0\
-\xa9\x1d\x81G\x00\xe7;\x0f\x00\x80\xcc%\x80$3O\
-$\x12(+\xaf\xe2\x00\x7f\xb8\x00\x8b\x98\x01\xa06Z\
-\xd5\x070\x05\xff\x98'\x93<=MI\xc9\xa9J\x0e\
-\xa0\xb7\xb3\x03\x89=\xc5\xf8\x170\xb1\x00|q\xf5\x00\
-\x00\xa4\xea\xc9\x98\x14\x8b\xc5P\xa6\xa8\x82zH\xc0\x98\
-\x19\xb8k\x05\xe6\x9c\x99\xfb\xe7Wd\x04\x90\xd2Sj\
-\x02\x88F\xa3\xdc<\x14\x0a\xa1\xb8\xb4\x02\xd7\x06\x05\xdc\
-f\x87\xe4\xa0\x01\x1cd\xc4\x04(;d\x06H=\x9c\
-s\x12\x99\xd3\xb9@ \xc5eU\xb8\xd8-\xa0\x7f:\
-c\xae}\x90i\xe0\xa3v\x99\x00\xfe]=\xa5&\xad\
-\xae\xaer\x88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xG\x00\xa5R\xe9v:\x9d\xbc\
-bJJo>\x94\xb4\xbe\xbe\xde\x99\x93\x93#\x99\x16\
-gSuV\x00\x8d\x8d\x8dn\x8b\xc5\x82\x81\x81\x81H\
-mm\xad377WV\xd3\xdd\x00\xf8\x7fFL\xc2\
-A\x99n\xd7\xdfC9V\x18\x85p\xc8\x04\x00\x00\x00\
-\x00IEND\xaeB`\x82\
-\x00\x00\x05+\
-\x89\
-PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
-\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\
-\x00\x00\x00\x04gAMA\x00\x00\xd6\xd8\xd4OX2\
-\x00\x00\x00\x19tEXtSoftware\
-\x00Adobe ImageRead\
-yq\xc9e<\x00\x00\x04\xbdIDATX\xc3\xed\
-WkL\x93W\x18>#q\xc92\xe9\x16\x97\xa8T\
-e8\x9d\x02\x15\xf6\x03\x872\x93\x01f,[p\xc4\
-0\xff`\xa2.\x1a:\x1dN\x03\xba1\x89[\xb3\x80\
-\xd9\x0c\x84\x02\x19X\x1c\x14\x8b\x85\xb2\x82\x95^\xe4f\
-\x0b\x8e1\xf8\xc3F\xcb-\x81\x15\xdc\xa8\xc2\x1c\x1b\xb7\
-ji\x91\xf2\xee\xbc\x87\xaf\x0c\xdc\xb8\x0da\xd9\xb2\x93\
-<\xed\x97\xf3}\xfd\xde\xe7\xbc\xef\xf3^J\x00\x80\xfc\
-\x93 \xff\x0a\x02t\x09(D\x14\xd9\x14q\x14\x01+\
-F\x80\xae\xddd\xdd\xc6f\x22L\xf8\x95\xc4\x8bG\xc8\
-\xa1\xd3\xf7\xc8\x8e\x97;82a+A \x85\x9c\xbe\
-0H.\xdd\x80\x19@2\xabyM\xf4\xbe\xfbr\x13\
-hd\x06\x91\x04^\xa3Q\xf4\x06\xee\x85G\xf5\xd0\xbd\
-\x83\xcbM \x9b\x9d\xf6@t/\xbd\x162= \x89\
-?H\xa5,\x1b\x01\x8c1y\xc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x12\x89\x84\x04,\xa1\x15\xdc\x01\xed\xff\xce\xe6\xf8\xe7\
-\x94Ok\xc7\xcf\xf8\xe6/\xdf&\xf6\xf57\x99|\xa6\
-\x83k\xfe.\xae\xf1-dk\x17\xad{\x7fN^V\
-s\xfaog\xd1wM\xee\xdc\x9d\xe2\x1b\xafvr\xfd\
-\xfau\x03\xa0gk\xd6?\x16\x8b\x99\xebx<\x8e\xe3\
-8%8\x04\xc0#\x00\x96%\x98\xcaA:\xde\xca\xfe\
-\xdf\xbdM\xd5\xae\xd7(\x84b\x08\xdbBY\x82lA\
-r\x7ff\x91O\xeef\x18\xb8\xear\xfa\x1fad\xd5\
-^\xae\x8f\xdcg2\xd7\xc6\x85\x0f\xee\x9b\x00\xed\x87\xa1\
-\xcd\xcd\xcd\xb4\xb5\xb5\x19755\xa1\xa1\x14 \x83\x1f\
-F\x16\xdcq\x15\xdf\xff\xe9o\xa8l\xd8H\xe2\xec;\
-L\x8f^\xc3\x89\x94\xb1\xb5y\x07\x9b[\xb6\xf3Iy\
-%c\x09\x97\xcff\xf2\xdc\x9d\xce2\xa1\xed\x88\x0dL\
-'\xe7\xd8\xb7+\xca\xfa%\x003{=k\xea\xea\xea\
-\x00\xccu*\x952\x00J+\x10\xa0\xb9Zp\xe1\x9d\
-c(,\xca\xe6\xc6\xd9\x10\x8fR\x94\x92{\xc3}$\
-e\x05\xdb\xda\x7fLM\xdb\xcb|<\x9cf\xd2_\xc0\
-\xcdx,\xcck/x \x00\xb5t:B\xa1\x90\x09\
--\xdd\xea\x1f\x8e\x01*\xf8>`\xc1\xc6\xb8\xa0P\x1c\
-#\x1c\x8bS\xb7\xa5\x96\x92xv}\x05\xe9\xac\xc7h\
-\xff\x9f\x98\xae\xbcL\xcb\xf6\x83\xb8\x0ba\xbc\x82\xa4X\
-\x94x\xda!\xc7B-\xaa\x80\xe3i\xa0\x96\xd5\x15\x01\
-\x00\xd6\xc7C\x84\xca#\xfc\xbfjc!\x9e\xa9\x0cs\
-\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8Y\x1dt\x8b\
-\x00=\x09\xc0\xd0\xd0\x90\xdb\xd3\xd3\x93\xd2N\xcf\xce\xce\
-\x9e.\xbd\x1d\xdf\x08\x02\xe8\xee\xea)\x00\x8c\x04\x84\x06\
-\x85\xaf\x08055U\xd0/\x22\xa9S\xa7N%\xc7\
-\xc7\xc7/\x03g\x81~\x1d\xec\xae\xb8\x09K\xdfv\xda\
-O&\x85\x01@\x08@aZ\xfc\xde\xe0`\xba\xbb\xbb\
-;\xa5\xdf\x8a\xcc$\xd0^\xeds\xcda\xed\x9aw3\
-n\x11`p\xf0\xfdt___\xfa\xcc\x993\xa6\xc5\
-\xa5\xd0\x8fx\x02\x89\xb5\x9ec!D\x18x\x13\xd8O\
-is\x06\xb4\xf8\xb1\xfa\x1f\xbd\xfa*_\xf2\xd8\x15\x9d\
-\x00\x00\x00\x00IEND\xaeB`\x82\
-\x00\x00\x04\xa3\
-\x89\
-PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
-\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\
-\x00\x00\x00\x04gAMA\x00\x00\xd6\xd8\xd4OX2\
-\x00\x00\x00\x19tEXtSoftware\
-\x00Adobe ImageRead\
-yq\xc9e<\x00\x00\x045IDATX\xc3\xe5\
-\x97\xcd\x8fTE\x14\xc5\x7f\xb7\xea\xd6{\xaf\xdbn\xc7\
-\xf9@\x9d\x89FM4\x99D\x8d\x1aH\x98\xc4\x8c\x1f\
-\x1b\xfe\x02L\x5c\xf1\x07\x18\x16.M\x5ckX\xc3\x8e\
-\xc4\x8d\x1b\x17\xce\x82htA\x5c\x18\x0d\xe2\xc4\xc6\x00\
-=`PQ\x19`\x02\xa2\x0e\x0c\x83\xd3\xfd^\xf7\x94\
-\x8b\xaa\xee\xf9`\xe6\x0d\x84Q\x16VR\xa9\xce{\xb7\
-\xeb\x9e:\xf7\xd4\xa9z\xea\xbd\xe7~6\xe5>\xb7>\
-\x80]\xbbv\xbd\x03\xec\xfd\x8f\xf2N5\x1a\x8d\x03\xeb\
-\x19\xd8\xbb\xef\xbd\xa3;\x1f\x1fv\x00\x9c<:\xcf\xcc\
-\x977X\x9c\xef\xdcS\xa6\xda\xa0\xf2\xdck\x03\xbc\xb8\
-g\x10\x80\x8b\x7f\x16|\xf8\xee\x1e\x80\xdb\x00p\xfc\xec\
-\x1c\xdf?0\x04x.\xfd\xb8\xc0\xfe\xb7\xceo\xcbr\
-\x0f\x1dy\x9a\x0b#\x96\xd3\x9f\x1fd\xfc\xd5}\x9bk\
-@E\xb0\x16@xp,#\xcb\xb2m\x0100\x96\
-a\x8dP\x1b|\x14#%\x22\x14+\xd8\x18\x91\xd5\x95\
-s\xe7\xce\x83*\xb8\x04\xd2\x14\xb2\x0c\xd2,\x8cI\x0a\
-I\x12\xdew:\x90\xe7\x90\xb7\xa1\xd5\x82v+\x8em\
-(r\xb2\xfa8\xd6\x0a\xe3\xaf\xbcIk\xf1\xfa\xe6\x00\
-\xac\x15\xac\x15\x04\xb0F\xd8\xbd{\xe7\x16k\xeb\x86\xae\
-\x80Z\xa8V\x81\xeamQ\x8d\xaf\x04\xb5\x82\xf7\xa0\xa6\
-\x84\x01g\x055\x82\x08\xa8\x0a\x95,\xc3# \x1e\x08\
-\xc0\xf0\x1e/\x02\xde#\x12&\x15|\x88#\xc4!\x1e\
-<!^@MX\x18@\xd7J\x89\x06\xac\xa0\xdac\
-\x00\x9a3\xbf\x05\x8aS\x07i\x02\x95\x04\xb24\xf6\x04\
-\x12\x07N\xa1\xe8@^@+\x8f\xbd\x05K9\xb4s\
-\xc8\x0bT\x87q=\x00*\xe5%p1@\xd509\
-\xf9\xd2\xd6\x0a\xf3>\xd0\xaf\x16\xaa\x1b\x8b\xf6\xd8'a\
-a\xbd\x1c%% \x00\xf0\x81\x8d4M\xa3:\xc3\xb3\
-\x98\x11\x89l\x07\xdac\x09V\x98_)F\xfca\xcd\
-r\x7fa\x1d-\xd1\x80:\x09TI\x18O4/\xe0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4\x88\x14\x9c\x0b'\x5c\xa0*\x00\xa8V\
-\xabdY\xd6\xa7\xb87\xdeis\x1a\xa9\x17AK\xad\
-8\x1e\xc7\xbd#\xb4\xd7\x8c1\x88D\xdf\x8f:\xb8\xab\
-\x9b\xaf5\xa8\x0d\xf3\xf6\x18.=\x8e\x83)m\xe3\xd5\
-\xdb\x12\xa9\xf7\xe5Vl\xad\xf4\x91\x0e\x8e\x0c\xc3\xf2\xef\
-\xdb\x02\xe0\xa1\x91a\xd4\xc2\xb5+\x97Y\x9c\xbf\xbe\x05\
-\x036\xf8\xc0`\xad\x02\x0b\xdb\xc3\xc0P\xad\xc2\xec\xc5\
-K\x9c\xfd\xee\x1b\xce\x9f\x9c\x9e\x03\xa66\x04`$^\
-J\x05\x12\x0b\xed\x91'\xa9=\x0co\x1f8\xc8f\xc7\
-\x81':\xf1*\xe75\x1e2\x81\x14(\xbap\xf9\xea\
-U\xce4\x8e\xd1\xfc\xfa\x8b\xb9\xd9\x1fN\x1d\x02\x0eo\
-\x08\xe0\xb3\x8f>\xe0\xa7\xd3'W\x99\xe9\xda\xa3\x86U\
-\xe6\xbb\x1e\x04\x1b<_\x1do|w\xee\x8f\xd9_\x0e\
-\x01\x87\x1b\x8d\xc6_\x1b\x01\x98\x9a\xfe\xf4\xe3\x7f\xf5s\
-l}\xf25\x00\xe2\xb7\xda\x81\xff\xdd\xd7\xf1?M\xf0\
-K\xb9\xe8F\x89\xaf\x00\x00\x00\x00IEND\xaeB\
-`\x82\
-"
-
-qt_resource_name = b"\
-\x00\x06\
-\x07\x03}\xc3\
-\x00i\
-\x00m\x00a\x00g\x00e\x00s\
-\x00\x08\
-\x06\xc1Y\x87\
-\x00o\
-\x00p\x00e\x00n\x00.\x00p\x00n\x00g\
-\x00\x07\
-\x04\xcaW\xa7\
-\x00n\
-\x00e\x00w\x00.\x00p\x00n\x00g\
-\x00\x08\
-\x06|Z\x07\
-\x00c\
-\x00o\x00p\x00y\x00.\x00p\x00n\x00g\
-\x00\x07\
-\x0a\xc7W\x87\
-\x00c\
-\x00u\x00t\x00.\x00p\x00n\x00g\
-\x00\x09\
-\x0a\xa8\xbaG\
-\x00p\
-\x00a\x00s\x00t\x00e\x00.\x00p\x00n\x00g\
-\x00\x08\
-\x08\xc8Xg\
-\x00s\
-\x00a\x00v\x00e\x00.\x00p\x00n\x00g\
-"
-
-qt_resource_struct = b"\
-\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
-\x00\x00\x00\x00\x00\x00\x00\x00\
-\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\x02\
-\x00\x00\x00\x00\x00\x00\x00\x00\
-\x00\x00\x00(\x00\x00\x00\x00\x00\x01\x00\x00\x08\x1d\
-\x00\x00\x01z\xe7\xee'\x09\
-\x00\x00\x00<\x00\x00\x00\x00\x00\x01\x00\x00\x0bu\
-\x00\x00\x01z\xe7\xee'\x09\
-\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
-\x00\x00\x01z\xe7\xee'\x09\
-\x00\x00\x00~\x00\x00\x00\x00\x00\x01\x00\x00\x1cS\
-\x00\x00\x01z\xe7\xee'\x09\
-\x00\x00\x00f\x00\x00\x00\x00\x00\x01\x00\x00\x15\xe2\
-\x00\x00\x01z\xe7\xee'\x09\
-\x00\x00\x00R\x00\x00\x00\x00\x00\x01\x00\x00\x10\xb3\
-\x00\x00\x01z\xe7\xee'\x09\
-"
-
-def qInitResources():
- QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
-
-def qCleanupResources():
- QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
-
-qInitResources()
diff --git a/examples/widgets/painting/basicdrawing/basicdrawing.py b/examples/widgets/painting/basicdrawing/basicdrawing.py
index c1f2a5b0c..858a8cd9f 100644
--- a/examples/widgets/painting/basicdrawing/basicdrawing.py
+++ b/examples/widgets/painting/basicdrawing/basicdrawing.py
@@ -6,11 +6,12 @@
from PySide6.QtCore import QPoint, QRect, QSize, Qt, qVersion
from PySide6.QtGui import (QBrush, QConicalGradient, QLinearGradient, QPainter,
- QPainterPath, QPalette, QPen, QPixmap, QPolygon, QRadialGradient)
+ QPainterPath, QPalette, QPen, QPixmap, QPolygon,
+ QRadialGradient)
from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox, QGridLayout,
- QLabel, QSpinBox, QWidget)
+ QLabel, QSpinBox, QWidget)
-import basicdrawing_rc
+import basicdrawing_rc # noqa: F401
class RenderArea(QWidget):
@@ -190,12 +191,9 @@ class Window(QWidget):
pen_join_label.setBuddy(self._pen_join_combo_box)
self._brush_style_combo_box = QComboBox()
- self._brush_style_combo_box.addItem("Linear Gradient",
- Qt.LinearGradientPattern)
- self._brush_style_combo_box.addItem("Radial Gradient",
- Qt.RadialGradientPattern)
- self._brush_style_combo_box.addItem("Conical Gradient",
- Qt.ConicalGradientPattern)
+ self._brush_style_combo_box.addItem("Linear Gradient", Qt.LinearGradientPattern)
+ self._brush_style_combo_box.addItem("Radial Gradient", Qt.RadialGradientPattern)
+ self._brush_style_combo_box.addItem("Conical Gradient", Qt.ConicalGradientPattern)
self._brush_style_combo_box.addItem("Texture", Qt.TexturePattern)
self._brush_style_combo_box.addItem("Solid", Qt.SolidPattern)
self._brush_style_combo_box.addItem("Horizontal", Qt.HorPattern)
@@ -260,24 +258,23 @@ class Window(QWidget):
self.setWindowTitle("Basic Drawing")
def shape_changed(self):
- shape = self._shape_combo_box.itemData(self._shape_combo_box.currentIndex(),
- id_role)
+ shape = self._shape_combo_box.itemData(self._shape_combo_box.currentIndex(), id_role)
self._render_area.set_shape(shape)
def pen_changed(self):
width = self._pen_width_spin_box.value()
style = Qt.PenStyle(self._pen_style_combo_box.itemData(
- self._pen_style_combo_box.currentIndex(), id_role))
+ self._pen_style_combo_box.currentIndex(), id_role))
cap = Qt.PenCapStyle(self._pen_cap_combo_box.itemData(
- self._pen_cap_combo_box.currentIndex(), id_role))
+ self._pen_cap_combo_box.currentIndex(), id_role))
join = Qt.PenJoinStyle(self._pen_join_combo_box.itemData(
- self._pen_join_combo_box.currentIndex(), id_role))
+ self._pen_join_combo_box.currentIndex(), id_role))
self._render_area.set_pen(QPen(Qt.blue, width, style, cap, join))
def brush_changed(self):
style = Qt.BrushStyle(self._brush_style_combo_box.itemData(
- self._brush_style_combo_box.currentIndex(), id_role))
+ self._brush_style_combo_box.currentIndex(), id_role))
if style == Qt.LinearGradientPattern:
linear_gradient = QLinearGradient(0, 0, 100, 100)
diff --git a/examples/widgets/painting/basicdrawing/basicdrawing.pyproject b/examples/widgets/painting/basicdrawing/basicdrawing.pyproject
index 9ecbfadcf..976bb9e35 100644
--- a/examples/widgets/painting/basicdrawing/basicdrawing.pyproject
+++ b/examples/widgets/painting/basicdrawing/basicdrawing.pyproject
@@ -1,3 +1,3 @@
{
- "files": ["basicdrawing_rc.py", "basicdrawing.qrc", "basicdrawing.py"]
+ "files": ["basicdrawing.qrc", "basicdrawing.py"]
}
diff --git a/examples/widgets/painting/concentriccircles/concentriccircles.py b/examples/widgets/painting/concentriccircles/concentriccircles.py
index 0edc9cb9f..d2c60178f 100644
--- a/examples/widgets/painting/concentriccircles/concentriccircles.py
+++ b/examples/widgets/painting/concentriccircles/concentriccircles.py
@@ -2,12 +2,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-"""PySide6 port of the widgets/painting/concentriccircles example from Qt v5.x, originating from PyQt"""
+"""PySide6 port of the widgets/painting/concentriccircles example from Qt v5.x, originating
+ from PyQt"""
from PySide6.QtCore import QRect, QRectF, QSize, Qt, QTimer
from PySide6.QtGui import QColor, QPainter, QPalette, QPen
from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QLabel,
- QSizePolicy, QWidget)
+ QSizePolicy, QWidget)
class CircleWidget(QWidget):
@@ -52,10 +53,10 @@ class CircleWidget(QWidget):
if self._float_based:
painter.drawEllipse(QRectF(-diameter / 2.0,
- -diameter / 2.0, diameter, diameter))
+ -diameter / 2.0, diameter, diameter))
else:
painter.drawEllipse(QRect(-diameter / 2,
- -diameter / 2, diameter, diameter))
+ -diameter / 2, diameter, diameter))
class Window(QWidget):
diff --git a/examples/widgets/painting/painter/painter.py b/examples/widgets/painting/painter/painter.py
index 49036ae00..2ca078ad9 100644
--- a/examples/widgets/painting/painter/painter.py
+++ b/examples/widgets/painting/painter/painter.py
@@ -9,7 +9,7 @@ from PySide6.QtWidgets import (
QStyle,
QColorDialog,
)
-from PySide6.QtCore import QPoint, Qt, QDir, Slot, QStandardPaths
+from PySide6.QtCore import Qt, Slot, QStandardPaths
from PySide6.QtGui import (
QMouseEvent,
QPaintEvent,
@@ -116,15 +116,17 @@ class MainWindow(QMainWindow):
self.bar = self.addToolBar("Menu")
self.bar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self._save_action = self.bar.addAction(
- qApp.style().standardIcon(QStyle.SP_DialogSaveButton), "Save", self.on_save
+ qApp.style().standardIcon(QStyle.SP_DialogSaveButton), # noqa: F821
+ "Save", self.on_save
)
self._save_action.setShortcut(QKeySequence.Save)
self._open_action = self.bar.addAction(
- qApp.style().standardIcon(QStyle.SP_DialogOpenButton), "Open", self.on_open
+ qApp.style().standardIcon(QStyle.SP_DialogOpenButton), # noqa: F821
+ "Open", self.on_open
)
self._open_action.setShortcut(QKeySequence.Open)
self.bar.addAction(
- qApp.style().standardIcon(QStyle.SP_DialogResetButton),
+ qApp.style().standardIcon(QStyle.SP_DialogResetButton), # noqa: F821
"Clear",
self.painter_widget.clear,
)
@@ -136,7 +138,8 @@ class MainWindow(QMainWindow):
self.setCentralWidget(self.painter_widget)
- self.set_color(Qt.black)
+ self.color = Qt.black
+ self.set_color(self.color)
self.mime_type_filters = ["image/png", "image/jpeg"]
@@ -175,19 +178,21 @@ class MainWindow(QMainWindow):
@Slot()
def on_color_clicked(self):
- color = QColorDialog.getColor(Qt.black, self)
+ color = QColorDialog.getColor(self.color, self)
+
if color:
self.set_color(color)
def set_color(self, color: QColor = Qt.black):
+ self.color = color
# Create color icon
pix_icon = QPixmap(32, 32)
- pix_icon.fill(color)
+ pix_icon.fill(self.color)
self.color_action.setIcon(QIcon(pix_icon))
- self.painter_widget.pen.setColor(color)
- self.color_action.setText(QColor(color).name())
+ self.painter_widget.pen.setColor(self.color)
+ self.color_action.setText(QColor(self.color).name())
if __name__ == "__main__":
diff --git a/examples/widgets/painting/plot/plot.py b/examples/widgets/painting/plot/plot.py
index 9d0dd016b..fd7ff9937 100644
--- a/examples/widgets/painting/plot/plot.py
+++ b/examples/widgets/painting/plot/plot.py
@@ -5,9 +5,8 @@ import math
import sys
from PySide6.QtWidgets import QWidget, QApplication
-from PySide6.QtCore import QPoint, QRect, QTimer, Qt, Slot
-from PySide6.QtGui import (QColor, QPainter, QPaintEvent, QPen, QPointList,
- QTransform)
+from PySide6.QtCore import QPoint, QRect, QTimer, Qt
+from PySide6.QtGui import QPainter, QPointList
WIDTH = 680
diff --git a/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst
new file mode 100644
index 000000000..c33c6660a
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst
@@ -0,0 +1,34 @@
+.. _rhi-widget-example:
+
+Simple RHI Widget Example
+=========================
+
+Shows how to render a triangle using ``QRhi``, Qt's 3D API and shading
+language abstraction layer.
+
+This example is, in many ways, the counterpart of the :ref:`rhi-window-example`
+in the QWidget world. The ``QRhiWidget`` subclass in this applications renders
+a single triangle, using a simple graphics pipeline with basic vertex and
+fragment shaders. Unlike the plain ``QWindow``-based application, this example
+does not need to worry about lower level details, such as setting up the window
+and the ``QRhi``, or dealing with swapchain and window events, as that is taken
+care of by the ``QWidget`` framework here. The instance of the ``QRhiWidget``
+subclass is added to a ``QVBoxLayout``. To keep the example minimal and
+compact, there are no further widgets or 3D content introduced.
+
+Once an instance of ``ExampleRhiWidget``, a ``QRhiWidget`` subclass, is added
+to a top-level widget's child hierarchy, the corresponding window automatically
+becomes a Direct 3D, Vulkan, Metal, or OpenGL-rendered window. The
+``QPainter``-rendered widget content, i.e. everything that is not a
+``QRhiWidget``, ``QOpenGLWidget``, or ``QQuickWidget``, is then uploaded to a
+texture, whereas the mentioned special widgets each render to a texture. The
+resulting set textures is composited together by the top-level widget's
+backingstore.
+
+As opposed to the C++ example, the cleanup is done by reimplementing
+``QRhiWidget.releaseResources()``, which is called from QWidget.closeEvent() of
+the top level widget to ensure a deterministic cleanup sequence.
+
+.. image:: simplerhiwidget.webp
+ :width: 400
+ :alt: Screenshot of the Simple RHI Widget example
diff --git a/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp
new file mode 100644
index 000000000..fdb8d20ec
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp
Binary files differ
diff --git a/examples/widgets/rhi/simplerhiwidget/examplewidget.py b/examples/widgets/rhi/simplerhiwidget/examplewidget.py
new file mode 100644
index 000000000..5b3e40f50
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/examplewidget.py
@@ -0,0 +1,135 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import numpy
+
+from PySide6.QtCore import (QFile, QIODevice)
+from PySide6.QtGui import (QColor, QMatrix4x4)
+from PySide6.QtGui import (QRhiBuffer,
+ QRhiDepthStencilClearValue,
+ QRhiShaderResourceBinding,
+ QRhiShaderStage,
+ QRhiVertexInputAttribute, QRhiVertexInputBinding,
+ QRhiVertexInputLayout, QRhiViewport,
+ QShader)
+from PySide6.QtWidgets import QRhiWidget
+from PySide6.support import VoidPtr
+
+VERTEX_DATA = numpy.array([ 0.0, 0.5, 1.0, 0.0, 0.0, # noqa E:201
+ -0.5, -0.5, 0.0, 1.0, 0.0, # noqa E:241
+ 0.5, -0.5, 0.0, 0.0, 1.0],
+ dtype=numpy.float32)
+
+
+def getShader(name):
+ f = QFile(name)
+ if f.open(QIODevice.ReadOnly):
+ return QShader.fromSerialized(f.readAll())
+ return QShader()
+
+
+class ExampleRhiWidget(QRhiWidget):
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.m_rhi = None
+ self.m_vbuf = None
+ self.m_ubuf = None
+ self.m_srb = None
+ self.m_pipeline = None
+ self.m_viewProjection = QMatrix4x4()
+ self.m_rotation = 0.0
+
+ def releaseResources(self):
+ self.m_pipeline.destroy()
+ del self.m_pipeline
+ self.m_pipeline = None
+ self.m_srb.destroy()
+ del self.m_srb
+ self.m_srb = None
+ self.m_ubuf.destroy()
+ del self.m_ubuf
+ self.m_ubuf = None
+ self.m_vbuf.destroy()
+ del self.m_vbuf
+ self.m_buf = None
+
+ def initialize(self, cb):
+ if self.m_rhi != self.rhi():
+ self.m_pipeline = None
+ self.m_rhi = self.rhi()
+
+ if not self.m_pipeline:
+ vertex_size = 4 * VERTEX_DATA.size
+ self.m_vbuf = self.m_rhi.newBuffer(QRhiBuffer.Immutable,
+ QRhiBuffer.VertexBuffer, vertex_size)
+ self.m_vbuf.create()
+
+ self.m_ubuf = self.m_rhi.newBuffer(QRhiBuffer.Dynamic,
+ QRhiBuffer.UniformBuffer, 64)
+ self.m_ubuf.create()
+
+ self.m_srb = self.m_rhi.newShaderResourceBindings()
+ bindings = [
+ QRhiShaderResourceBinding.uniformBuffer(0, QRhiShaderResourceBinding.VertexStage,
+ self.m_ubuf)
+ ]
+ self.m_srb.setBindings(bindings)
+ self.m_srb.create()
+
+ self.m_pipeline = self.m_rhi.newGraphicsPipeline()
+ stages = [
+ QRhiShaderStage(QRhiShaderStage.Vertex,
+ getShader(":/shader_assets/color.vert.qsb")),
+ QRhiShaderStage(QRhiShaderStage.Fragment,
+ getShader(":/shader_assets/color.frag.qsb"))
+ ]
+ self.m_pipeline.setShaderStages(stages)
+ inputLayout = QRhiVertexInputLayout()
+ input_bindings = [QRhiVertexInputBinding(5 * 4)] # sizeof(float)
+ inputLayout.setBindings(input_bindings)
+ attributes = [ # 4: sizeof(float)
+ QRhiVertexInputAttribute(0, 0, QRhiVertexInputAttribute.Float2, 0),
+ QRhiVertexInputAttribute(0, 1, QRhiVertexInputAttribute.Float3, 2 * 4)
+ ]
+ inputLayout.setAttributes(attributes)
+ self.m_pipeline.setVertexInputLayout(inputLayout)
+ self.m_pipeline.setShaderResourceBindings(self.m_srb)
+ self.m_pipeline.setRenderPassDescriptor(self.renderTarget().renderPassDescriptor())
+ self.m_pipeline.create()
+
+ resourceUpdates = self.m_rhi.nextResourceUpdateBatch()
+ resourceUpdates.uploadStaticBuffer(self.m_vbuf, VoidPtr(VERTEX_DATA.tobytes(),
+ vertex_size))
+ cb.resourceUpdate(resourceUpdates)
+
+ outputSize = self.renderTarget().pixelSize()
+ self.m_viewProjection = self.m_rhi.clipSpaceCorrMatrix()
+ r = float(outputSize.width()) / float(outputSize.height())
+ self.m_viewProjection.perspective(45.0, r, 0.01, 1000.0)
+ self.m_viewProjection.translate(0, 0, -4)
+
+ def render(self, cb):
+ resourceUpdates = self.m_rhi.nextResourceUpdateBatch()
+ self.m_rotation += 1.0
+ modelViewProjection = self.m_viewProjection
+ modelViewProjection.rotate(self.m_rotation, 0, 1, 0)
+ projection = numpy.array(modelViewProjection.data(),
+ dtype=numpy.float32)
+ resourceUpdates.updateDynamicBuffer(self.m_ubuf, 0, 64,
+ projection.tobytes())
+ clearColor = QColor.fromRgbF(0.4, 0.7, 0.0, 1.0)
+ cv = QRhiDepthStencilClearValue(1.0, 0)
+ cb.beginPass(self.renderTarget(), clearColor, cv, resourceUpdates)
+
+ cb.setGraphicsPipeline(self.m_pipeline)
+ outputSize = self.renderTarget().pixelSize()
+ cb.setViewport(QRhiViewport(0, 0, outputSize.width(),
+ outputSize.height()))
+ cb.setShaderResources()
+ vbufBinding = (self.m_vbuf, 0)
+ cb.setVertexInput(0, [vbufBinding])
+ cb.draw(3)
+ cb.endPass()
+
+ self.update()
diff --git a/examples/widgets/rhi/simplerhiwidget/main.py b/examples/widgets/rhi/simplerhiwidget/main.py
new file mode 100644
index 000000000..59be81ddc
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/main.py
@@ -0,0 +1,35 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+"""PySide6 port of the Qt Simple RHI Widget Example example from Qt v6.x"""
+
+import sys
+
+from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget
+
+from examplewidget import ExampleRhiWidget
+import rc_simplerhiwidget # noqa F:401
+
+
+class Widget(QWidget):
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ layout = QVBoxLayout(self)
+ self._rhi_widget = ExampleRhiWidget(self)
+ layout.addWidget(self._rhi_widget)
+
+ def closeEvent(self, e):
+ self._rhi_widget.releaseResources()
+ e.accept()
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+
+ w = Widget()
+ w.resize(1280, 720)
+ w.show()
+ exit_code = app.exec()
+ del w
+ sys.exit(exit_code)
diff --git a/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py b/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py
new file mode 100644
index 000000000..ee8b41242
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py
@@ -0,0 +1,163 @@
+# Resource object code (Python 3)
+# Created by: object code
+# Created by: The Resource Compiler for Qt version 6.7.0
+# WARNING! All changes made in this file will be lost!
+
+from PySide6 import QtCore
+
+qt_resource_data = b"\
+\x00\x00\x02\xe2\
+\x00\
+\x00\x07\xc4x\x9c\xb5T]k\xd4@\x14\x9d\xed\xa6]\
+\x9b\xd6\xda\x0f\xd07\x19\xe9\xcb\x16%\xa6\xb5\x15q\xdd\
+\xfa\xb0U)\x14Z\xdbR\x84e\x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1b\x96$&=\x8a\x95\x871\xff\xad\
+\xce\xe8\xbf\x83J\xcb\xcc\xd9\xb5\xae\xea'\xc7\xdf%\xe1\
+\xb4\xa2\
+"
+
+qt_resource_name = b"\
+\x00\x0d\
+\x06E\xc5\xd3\
+\x00s\
+\x00h\x00a\x00d\x00e\x00r\x00_\x00a\x00s\x00s\x00e\x00t\x00s\
+\x00\x0e\
+\x04\x16\xeb\xb2\
+\x00c\
+\x00o\x00l\x00o\x00r\x00.\x00f\x00r\x00a\x00g\x00.\x00q\x00s\x00b\
+\x00\x0e\
+\x00\xfb\xe9\x92\
+\x00c\
+\x00o\x00l\x00o\x00r\x00.\x00v\x00e\x00r\x00t\x00.\x00q\x00s\x00b\
+"
+
+qt_resource_struct = b"\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
+\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
+\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00B\x00\x00\x00\x00\x00\x01\x00\x00\x02\xe6\
+\x00\x00\x01\x8a!\x0c\xa5\xeb\
+\x00\x00\x00 \x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
+\x00\x00\x01\x8a!\x0c\xa5\xeb\
+"
+
+def qInitResources():
+ QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+def qCleanupResources():
+ QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+qInitResources()
diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb
new file mode 100644
index 000000000..32bd2d595
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb
Binary files differ
diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb
new file mode 100644
index 000000000..bf97035d7
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb
Binary files differ
diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.frag b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag
new file mode 100644
index 000000000..375587662
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag
@@ -0,0 +1,10 @@
+#version 440
+
+layout(location = 0) in vec3 v_color;
+
+layout(location = 0) out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(v_color, 1.0);
+}
diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.vert b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert
new file mode 100644
index 000000000..e876f290e
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert
@@ -0,0 +1,16 @@
+#version 440
+
+layout(location = 0) in vec4 position;
+layout(location = 1) in vec3 color;
+
+layout(location = 0) out vec3 v_color;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+};
+
+void main()
+{
+ v_color = color;
+ gl_Position = mvp * position;
+}
diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject
new file mode 100644
index 000000000..ff0d62755
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject
@@ -0,0 +1,4 @@
+{
+ "files": ["main.py","examplewidget.py", "simplerhiwidget.qrc",
+ "shaders/color.frag", "shaders/color.vert"]
+}
diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc
new file mode 100644
index 000000000..ddc6dfbe5
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>shader_assets/color.vert.qsb</file>
+ <file>shader_assets/color.frag.qsb</file>
+</qresource>
+</RCC>
diff --git a/examples/widgets/richtext/orderform/orderform.py b/examples/widgets/richtext/orderform/orderform.py
index 9f16c40a2..9725624c3 100644
--- a/examples/widgets/richtext/orderform/orderform.py
+++ b/examples/widgets/richtext/orderform/orderform.py
@@ -6,14 +6,14 @@
import sys
-from PySide6.QtCore import QDate, Qt, Signal, Slot
+from PySide6.QtCore import QDate, Qt, Slot
from PySide6.QtGui import (QFont, QTextCharFormat, QTextCursor,
QTextFrameFormat, QTextLength, QTextTableFormat)
from PySide6.QtWidgets import (QApplication, QCheckBox, QDialog,
QDialogButtonBox, QGridLayout, QLabel,
QLineEdit, QMainWindow, QMenu, QMessageBox,
QTableWidget, QTableWidgetItem, QTabWidget,
- QTextEdit, QWidget)
+ QTextEdit)
from PySide6.QtPrintSupport import QAbstractPrintDialog, QPrintDialog, QPrinter
@@ -89,8 +89,7 @@ class MainWindow(QMainWindow):
body_frame_format.setWidth(QTextLength(QTextLength.PercentageLength, 100))
cursor.insertFrame(body_frame_format)
- cursor.insertText("I would like to place an order for the following "
- "items:", text_format)
+ cursor.insertText("I would like to place an order for the following items:", text_format)
cursor.insertBlock()
cursor.insertBlock()
@@ -121,17 +120,17 @@ class MainWindow(QMainWindow):
cursor.insertBlock()
cursor.insertText("Please update my records to take account of the "
- "following privacy information:")
+ "following privacy information:")
cursor.insertBlock()
offers_table = cursor.insertTable(2, 2)
cursor = offers_table.cellAt(0, 1).firstCursorPosition()
cursor.insertText("I want to receive more information about your "
- "company's products and special offers.", text_format)
+ "company's products and special offers.", text_format)
cursor = offers_table.cellAt(1, 1).firstCursorPosition()
cursor.insertText("I do not want to receive any promotional "
- "information from your company.", text_format)
+ "information from your company.", text_format)
if sendOffers:
cursor = offers_table.cellAt(0, 0).firstCursorPosition()
@@ -153,16 +152,18 @@ class MainWindow(QMainWindow):
def create_sample(self):
dialog = DetailsDialog('Dialog with default values', self)
self.create_letter('Mr Smith',
- '12 High Street\nSmall Town\nThis country',
- dialog.order_items(), True)
+ '12 High Street\nSmall Town\nThis country',
+ dialog.order_items(), True)
+ @Slot()
def open_dialog(self):
dialog = DetailsDialog("Enter Customer Details", self)
if dialog.exec() == QDialog.Accepted:
self.create_letter(dialog.sender_name(), dialog.sender_address(),
- dialog.order_items(), dialog.send_offers())
+ dialog.order_items(), dialog.send_offers())
+ @Slot()
def print_file(self):
editor = self.letters.currentWidget()
printer = QPrinter()
@@ -191,8 +192,7 @@ class DetailsDialog(QDialog):
self._name_edit = QLineEdit()
self._address_edit = QTextEdit()
- self._offers_check_box = QCheckBox("Send information about "
- "products and special offers:")
+ self._offers_check_box = QCheckBox("Send information about products and special offers:")
self.setup_items_table()
@@ -241,15 +241,16 @@ class DetailsDialog(QDialog):
def send_offers(self):
return self._offers_check_box.isChecked()
+ @Slot()
def verify(self):
if self._name_edit.text() and self._address_edit.toPlainText():
self.accept()
return
answer = QMessageBox.warning(self, "Incomplete Form",
- "The form does not contain all the necessary information.\n"
- "Do you want to discard it?",
- QMessageBox.Yes, QMessageBox.No)
+ "The form does not contain all the necessary information.\n"
+ "Do you want to discard it?",
+ QMessageBox.Yes, QMessageBox.No)
if answer == QMessageBox.Yes:
self.reject()
diff --git a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
index c329eefd6..021328977 100644
--- a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
+++ b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
@@ -12,7 +12,7 @@ from PySide6.QtCore import (QFile, Qt, QTextStream)
from PySide6.QtGui import (QColor, QFont, QFontDatabase, QKeySequence,
QSyntaxHighlighter, QTextCharFormat)
from PySide6.QtWidgets import (QApplication, QFileDialog, QMainWindow,
- QPlainTextEdit)
+ QPlainTextEdit)
class MainWindow(QMainWindow):
@@ -81,7 +81,7 @@ class MainWindow(QMainWindow):
quit_act.triggered.connect(self.close)
help_menu = self.menuBar().addMenu("&Help")
- help_menu.addAction("About &Qt", qApp.aboutQt)
+ help_menu.addAction("About &Qt", qApp.aboutQt) # noqa: F821
class Highlighter(QSyntaxHighlighter):
diff --git a/examples/widgets/richtext/textedit/main.py b/examples/widgets/richtext/textedit/main.py
index a51a4d34f..330ea5fc5 100644
--- a/examples/widgets/richtext/textedit/main.py
+++ b/examples/widgets/richtext/textedit/main.py
@@ -7,12 +7,11 @@ import sys
from argparse import ArgumentParser, RawTextHelpFormatter
from PySide6.QtCore import QCoreApplication, qVersion
-from PySide6.QtGui import QScreen
from PySide6.QtWidgets import QApplication
from textedit import TextEdit
-import textedit_rc
+import textedit_rc # noqa: F401
if __name__ == '__main__':
diff --git a/examples/widgets/richtext/textedit/textedit.py b/examples/widgets/richtext/textedit/textedit.py
index 12eddc6c5..8019446f0 100644
--- a/examples/widgets/richtext/textedit/textedit.py
+++ b/examples/widgets/richtext/textedit/textedit.py
@@ -2,16 +2,16 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import sys
-from PySide6.QtCore import (QCoreApplication, QDir, QFile, QFileInfo, QMimeData,
+from PySide6.QtCore import (QCoreApplication, QDir, QFile, QFileInfo,
QMimeDatabase, QUrl, Qt, Slot)
-from PySide6.QtGui import (QAction, QActionGroup, QColor, QGuiApplication, QClipboard,
- QCloseEvent, QFont, QFontDatabase, QFontInfo, QIcon,
+from PySide6.QtGui import (QAction, QActionGroup, QColor, QGuiApplication,
+ QFont, QFontDatabase, QFontInfo, QIcon,
QKeySequence, QPalette, QPixmap, QTextBlockFormat,
QTextCharFormat, QTextCursor, QTextDocumentWriter,
- QTextFormat, QTextList, QTextListFormat)
+ QTextFormat, QTextListFormat)
from PySide6.QtWidgets import (QApplication, QMainWindow, QColorDialog, QComboBox,
- QDialog, QFileDialog, QFontComboBox, QStatusBar,
- QTextEdit, QToolBar, QMenu, QMenuBar, QMessageBox)
+ QDialog, QFileDialog, QFontComboBox,
+ QTextEdit, QMessageBox)
from PySide6.QtPrintSupport import (QAbstractPrintDialog, QPrinter,
QPrintDialog, QPrintPreviewDialog)
@@ -55,7 +55,7 @@ class TextEdit(QMainWindow):
help_menu = self.menuBar().addMenu("Help")
help_menu.addAction("About", self.about)
- help_menu.addAction("About &Qt", qApp.aboutQt)
+ help_menu.addAction("About &Qt", qApp.aboutQt) # noqa: F821
text_font = QFont("Helvetica")
text_font.setStyleHint(QFont.SansSerif)
@@ -101,13 +101,14 @@ class TextEdit(QMainWindow):
tb = self.addToolBar("File self.actions")
menu = self.menuBar().addMenu("&File")
- icon = QIcon.fromTheme("document-new", QIcon(RSRC_PATH + "/filenew.png"))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentNew,
+ QIcon(RSRC_PATH + "/filenew.png"))
a = menu.addAction(icon, "&New", self.file_new)
tb.addAction(a)
a.setPriority(QAction.LowPriority)
a.setShortcut(QKeySequence.New)
- icon = QIcon.fromTheme("document-open",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentOpen,
QIcon(RSRC_PATH + "/fileopen.png"))
a = menu.addAction(icon, "&Open...", self.file_open)
a.setShortcut(QKeySequence.Open)
@@ -115,7 +116,7 @@ class TextEdit(QMainWindow):
menu.addSeparator()
- icon = QIcon.fromTheme("document-save",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentSave,
QIcon(RSRC_PATH + "/filesave.png"))
self._action_save = menu.addAction(icon, "&Save", self.file_save)
self._action_save.setShortcut(QKeySequence.Save)
@@ -126,7 +127,7 @@ class TextEdit(QMainWindow):
a.setPriority(QAction.LowPriority)
menu.addSeparator()
- icon = QIcon.fromTheme("document-print",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.DocumentPrint,
QIcon(RSRC_PATH + "/fileprint.png"))
a = menu.addAction(icon, "&Print...", self.file_print)
a.setPriority(QAction.LowPriority)
@@ -151,32 +152,36 @@ class TextEdit(QMainWindow):
tb = self.addToolBar("Edit self.actions")
menu = self.menuBar().addMenu("&Edit")
- icon = QIcon.fromTheme("edit-undo",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditUndo,
QIcon(RSRC_PATH + "/editundo.png"))
self._action_undo = menu.addAction(icon, "&Undo", self._text_edit.undo)
self._action_undo.setShortcut(QKeySequence.Undo)
tb.addAction(self._action_undo)
- icon = QIcon.fromTheme("edit-redo", QIcon(RSRC_PATH + "/editredo.png"))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditRedo,
+ QIcon(RSRC_PATH + "/editredo.png"))
self._action_redo = menu.addAction(icon, "&Redo", self._text_edit.redo)
self._action_redo.setPriority(QAction.LowPriority)
self._action_redo.setShortcut(QKeySequence.Redo)
tb.addAction(self._action_redo)
menu.addSeparator()
- icon = QIcon.fromTheme("edit-cut", QIcon(RSRC_PATH + "/editcut.png"))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCut,
+ QIcon(RSRC_PATH + "/editcut.png"))
self._action_cut = menu.addAction(icon, "Cu&t", self._text_edit.cut)
self._action_cut.setPriority(QAction.LowPriority)
self._action_cut.setShortcut(QKeySequence.Cut)
tb.addAction(self._action_cut)
- icon = QIcon.fromTheme("edit-copy", QIcon(RSRC_PATH + "/editcopy.png"))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditCopy,
+ QIcon(RSRC_PATH + "/editcopy.png"))
self._action_copy = menu.addAction(icon, "&Copy", self._text_edit.copy)
self._action_copy.setPriority(QAction.LowPriority)
self._action_copy.setShortcut(QKeySequence.Copy)
tb.addAction(self._action_copy)
- icon = QIcon.fromTheme("edit-paste", QIcon(RSRC_PATH + "/editpaste.png"))
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.EditPaste,
+ QIcon(RSRC_PATH + "/editpaste.png"))
self._action_paste = menu.addAction(icon, "&Paste", self._text_edit.paste)
self._action_paste.setPriority(QAction.LowPriority)
self._action_paste.setShortcut(QKeySequence.Paste)
@@ -190,7 +195,7 @@ class TextEdit(QMainWindow):
tb = self.addToolBar("Format self.actions")
menu = self.menuBar().addMenu("F&ormat")
- icon = QIcon.fromTheme("format-text-bold",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatTextBold,
QIcon(RSRC_PATH + "/textbold.png"))
self._action_text_bold = menu.addAction(icon, "&Bold", self.text_bold)
self._action_text_bold.setShortcut(Qt.CTRL | Qt.Key_B)
@@ -201,7 +206,7 @@ class TextEdit(QMainWindow):
tb.addAction(self._action_text_bold)
self._action_text_bold.setCheckable(True)
- icon = QIcon.fromTheme("format-text-italic",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatTextItalic,
QIcon(RSRC_PATH + "/textitalic.png"))
self._action_text_italic = menu.addAction(icon, "&Italic", self.text_italic)
self._action_text_italic.setPriority(QAction.LowPriority)
@@ -212,7 +217,7 @@ class TextEdit(QMainWindow):
tb.addAction(self._action_text_italic)
self._action_text_italic.setCheckable(True)
- icon = QIcon.fromTheme("format-text-underline",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatTextUnderline,
QIcon(RSRC_PATH + "/textunder.png"))
self._action_text_underline = menu.addAction(icon, "&Underline",
self.text_underline)
@@ -226,36 +231,36 @@ class TextEdit(QMainWindow):
menu.addSeparator()
- icon = QIcon.fromTheme("format-justify-left",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatJustifyLeft,
QIcon(RSRC_PATH + "/textleft.png"))
self._action_align_left = QAction(icon, "&Left", self)
self._action_align_left.setShortcut(Qt.CTRL | Qt.Key_L)
self._action_align_left.setCheckable(True)
self._action_align_left.setPriority(QAction.LowPriority)
- icon = QIcon.fromTheme("format-justify-center",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatJustifyCenter,
QIcon(RSRC_PATH + "/textcenter.png"))
self._action_align_center = QAction(icon, "C&enter", self)
self._action_align_center.setShortcut(Qt.CTRL | Qt.Key_E)
self._action_align_center.setCheckable(True)
self._action_align_center.setPriority(QAction.LowPriority)
- icon = QIcon.fromTheme("format-justify-right",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatJustifyRight,
QIcon(RSRC_PATH + "/textright.png"))
self._action_align_right = QAction(icon, "&Right", self)
self._action_align_right.setShortcut(Qt.CTRL | Qt.Key_R)
self._action_align_right.setCheckable(True)
self._action_align_right.setPriority(QAction.LowPriority)
- icon = QIcon.fromTheme("format-justify-fill",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatJustifyFill,
QIcon(RSRC_PATH + "/textjustify.png"))
self._action_align_justify = QAction(icon, "&Justify", self)
self._action_align_justify.setShortcut(Qt.CTRL | Qt.Key_J)
self._action_align_justify.setCheckable(True)
self._action_align_justify.setPriority(QAction.LowPriority)
- icon = QIcon.fromTheme("format-indent-more",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatIndentMore,
QIcon(RSRC_PATH + "/format-indent-more.png"))
self._action_indent_more = menu.addAction(icon, "&Indent", self.indent)
self._action_indent_more.setShortcut(Qt.CTRL | Qt.Key_BracketRight)
self._action_indent_more.setPriority(QAction.LowPriority)
- icon = QIcon.fromTheme("format-indent-less",
+ icon = QIcon.fromTheme(QIcon.ThemeIcon.FormatIndentLess,
QIcon(RSRC_PATH + "/format-indent-less.png"))
self._action_indent_less = menu.addAction(icon, "&Unindent",
self.unindent)
@@ -406,7 +411,7 @@ class TextEdit(QMainWindow):
@Slot()
def file_save(self):
if not self._file_name or self._file_name.startswith(":/"):
- return fileSaveAs()
+ return self.file_save_as()
writer = QTextDocumentWriter(self._file_name)
document = self._text_edit.document()
@@ -621,7 +626,7 @@ class TextEdit(QMainWindow):
above = QTextCursor(cursor)
above.movePosition(QTextCursor.Up)
if (above.currentList()
- and list_fmt.indent() + amount == above.currentList().format().indent()):
+ and list_fmt.indent() + amount == above.currentList().format().indent()):
above.currentList().add(cursor.block())
else:
list_fmt.setIndent(list_fmt.indent() + amount)
diff --git a/examples/widgets/richtext/textobject/textobject.py b/examples/widgets/richtext/textobject/textobject.py
index 3bc5f4bd2..9ab7bf8ae 100644
--- a/examples/widgets/richtext/textobject/textobject.py
+++ b/examples/widgets/richtext/textobject/textobject.py
@@ -8,9 +8,8 @@ import os
from pathlib import Path
import sys
-from PySide6.QtCore import QFile, QIODevice, QObject, QSizeF, Qt
-from PySide6.QtGui import (QTextCharFormat, QTextFormat, QTextObjectInterface,
- QPyTextObject)
+from PySide6.QtCore import QFile, QIODevice, QSizeF, Slot
+from PySide6.QtGui import (QTextCharFormat, QTextFormat, QPyTextObject)
from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
QVBoxLayout, QWidget)
@@ -51,6 +50,7 @@ class Window(QWidget):
self.setWindowTitle(self.tr("Text Object Example"))
+ @Slot()
def insert_text_object(self):
file_name = self._file_name_line_edit.text()
file = QFile(file_name)
diff --git a/examples/widgets/state-machine/eventtrans/eventtrans.py b/examples/widgets/state-machine/eventtrans/eventtrans.py
deleted file mode 100644
index b1c74a21f..000000000
--- a/examples/widgets/state-machine/eventtrans/eventtrans.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QEvent, QRect, Qt
-from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
-from PySide6.QtStateMachine import QEventTransition, QState, QStateMachine
-
-
-class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- button = QPushButton(self)
- button.setGeometry(QRect(100, 100, 100, 100))
-
- machine = QStateMachine(self)
- s1 = QState()
- s1.assignProperty(button, 'text', 'Outside')
- s2 = QState()
- s2.assignProperty(button, 'text', 'Inside')
-
- enter_transition = QEventTransition(button, QEvent.Enter)
- enter_transition.setTargetState(s2)
- s1.addTransition(enter_transition)
-
- leave_transition = QEventTransition(button, QEvent.Leave)
- leave_transition.setTargetState(s1)
- s2.addTransition(leave_transition)
-
- s3 = QState()
- s3.assignProperty(button, 'text', 'Pressing...')
-
- press_transition = QEventTransition(button, QEvent.MouseButtonPress)
- press_transition.setTargetState(s3)
- s2.addTransition(press_transition)
-
- release_transition = QEventTransition(button, QEvent.MouseButtonRelease)
- release_transition.setTargetState(s2)
- s3.addTransition(release_transition)
-
- machine.addState(s1)
- machine.addState(s2)
- machine.addState(s3)
-
- machine.setInitialState(s1)
- machine.start()
-
- self.setCentralWidget(button)
- self.show()
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- main_win = MainWindow()
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/eventtrans/eventtrans.pyproject b/examples/widgets/state-machine/eventtrans/eventtrans.pyproject
deleted file mode 100644
index b2f660a8f..000000000
--- a/examples/widgets/state-machine/eventtrans/eventtrans.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["eventtrans.py"]
-}
diff --git a/examples/widgets/state-machine/factstates/factstates.py b/examples/widgets/state-machine/factstates/factstates.py
deleted file mode 100644
index aacf8f19b..000000000
--- a/examples/widgets/state-machine/factstates/factstates.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QCoreApplication, QObject, Qt, Property, Signal
-from PySide6.QtStateMachine import (QFinalState, QSignalTransition, QState,
- QStateMachine)
-
-
-class Factorial(QObject):
- x_changed = Signal(int)
-
- def __init__(self):
- super().__init__()
- self.xval = -1
- self.facval = 1
-
- def get_x(self):
- return self.xval
-
- def set_x(self, x):
- if self.xval == x:
- return
- self.xval = x
- self.x_changed.emit(x)
- x = Property(int, get_x, set_x)
-
- def get_fact(self):
- return self.facval
-
- def set_fact(self, fac):
- self.facval = fac
-
- fac = Property(int, get_fact, set_fact)
-
-
-class FactorialLoopTransition(QSignalTransition):
- def __init__(self, fact):
- super().__init__(fact.x_changed)
- self.fact = fact
-
- def eventTest(self, e):
- if not super(FactorialLoopTransition, self).eventTest(e):
- return False
- return e.arguments()[0] > 1
-
- def onTransition(self, e):
- x = e.arguments()[0]
- fac = self.fact.fac
- self.fact.fac = x * fac
- self.fact.x = x - 1
-
-
-class FactorialDoneTransition(QSignalTransition):
- def __init__(self, fact):
- super().__init__(fact.x_changed)
- self.fact = fact
-
- def eventTest(self, e):
- if not super(FactorialDoneTransition, self).eventTest(e):
- return False
- return e.arguments()[0] <= 1
-
- def onTransition(self, e):
- print(self.fact.fac)
-
-
-if __name__ == '__main__':
- app = QCoreApplication(sys.argv)
- factorial = Factorial()
- machine = QStateMachine()
-
- compute = QState(machine)
- compute.assignProperty(factorial, 'fac', 1)
- compute.assignProperty(factorial, 'x', 6)
- compute.addTransition(FactorialLoopTransition(factorial))
-
- done = QFinalState(machine)
- done_transition = FactorialDoneTransition(factorial)
- done_transition.setTargetState(done)
- compute.addTransition(done_transition)
-
- machine.setInitialState(compute)
- machine.finished.connect(app.quit)
- machine.start()
-
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/factstates/factstates.pyproject b/examples/widgets/state-machine/factstates/factstates.pyproject
deleted file mode 100644
index 751a5005b..000000000
--- a/examples/widgets/state-machine/factstates/factstates.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["factstates.py"]
-}
diff --git a/examples/widgets/state-machine/ping_pong/ping_pong.py b/examples/widgets/state-machine/ping_pong/ping_pong.py
deleted file mode 100644
index d5c18eb28..000000000
--- a/examples/widgets/state-machine/ping_pong/ping_pong.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QCoreApplication, QEvent
-from PySide6.QtStateMachine import QAbstractTransition, QState, QStateMachine
-
-
-class PingEvent(QEvent):
- def __init__(self):
- super().__init__(QEvent.Type(QEvent.User + 2))
-
-
-class PongEvent(QEvent):
- def __init__(self):
- super().__init__(QEvent.Type(QEvent.User + 3))
-
-
-class Pinger(QState):
- def __init__(self, parent):
- super().__init__(parent)
-
- def onEntry(self, e):
- self.p = PingEvent()
- self.machine().postEvent(self.p)
- print('ping?')
-
-
-class PongTransition(QAbstractTransition):
- def eventTest(self, e):
- return e.type() == QEvent.User + 3
-
- def onTransition(self, e):
- self.p = PingEvent()
- machine.postDelayedEvent(self.p, 500)
- print('ping?')
-
-
-class PingTransition(QAbstractTransition):
- def eventTest(self, e):
- return e.type() == QEvent.User + 2
-
- def onTransition(self, e):
- self.p = PongEvent()
- machine.postDelayedEvent(self.p, 500)
- print('pong!')
-
-
-if __name__ == '__main__':
- app = QCoreApplication(sys.argv)
-
- machine = QStateMachine()
- group = QState(QState.ParallelStates)
- group.setObjectName('group')
-
- pinger = Pinger(group)
- pinger.setObjectName('pinger')
- pinger.addTransition(PongTransition())
-
- ponger = QState(group)
- ponger.setObjectName('ponger')
- ponger.addTransition(PingTransition())
-
- machine.addState(group)
- machine.setInitialState(group)
- machine.start()
-
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/ping_pong/ping_pong.pyproject b/examples/widgets/state-machine/ping_pong/ping_pong.pyproject
deleted file mode 100644
index 7fb430352..000000000
--- a/examples/widgets/state-machine/ping_pong/ping_pong.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["ping_pong.py"]
-}
diff --git a/examples/widgets/state-machine/rogue/rogue.py b/examples/widgets/state-machine/rogue/rogue.py
deleted file mode 100644
index a43d4d1bc..000000000
--- a/examples/widgets/state-machine/rogue/rogue.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import (QEvent, QPoint, QRandomGenerator, QSize, Qt,
- Property)
-from PySide6.QtGui import QFont, QFontMetrics, QFontDatabase, QPainter
-from PySide6.QtWidgets import QApplication, QMainWindow
-from PySide6.QtStateMachine import (QEventTransition, QFinalState,
- QKeyEventTransition, QState, QStateMachine)
-
-
-class MovementTransition(QEventTransition):
- def __init__(self, window):
- super().__init__(window, QEvent.KeyPress)
- self.window = window
-
- def eventTest(self, event):
- if (event.type() == QEvent.StateMachineWrapped and
- event.event().type() == QEvent.KeyPress):
- key = event.event().key()
- return (key == Qt.Key_2 or key == Qt.Key_8 or
- key == Qt.Key_6 or key == Qt.Key_4)
- return False
-
- def onTransition(self, event):
- key = event.event().key()
- if key == Qt.Key_4:
- self.window.move_player(self.window.left)
- if key == Qt.Key_8:
- self.window.move_player(self.window.Up)
- if key == Qt.Key_6:
- self.window.move_player(self.window.right)
- if key == Qt.Key_2:
- self.window.move_player(self.window.down)
-
-
-class Custom(QState):
- def __init__(self, parent, mw):
- super().__init__(parent)
- self.mw = mw
-
- def onEntry(self, e):
- print(self.mw.status)
-
-
-class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.pX = 5
- self.pY = 5
- self.width = 35
- self.height = 20
- self._status_str = ''
-
- font = QFont()
- if 'Monospace' in QFontDatabase.families():
- font = QFont('Monospace', 12)
- else:
- for family in QFontDatabase.families():
- if QFontDatabase.isFixedPitch(family):
- font = QFont(family, 12)
- self.setFont(font)
-
- self.setup_map()
- self.build_machine()
- self.show()
-
- def setup_map(self):
- self.map = []
- generator = QRandomGenerator().global_()
- for x in range(self.width):
- column = []
- for y in range(self.height):
- if (x == 0 or x == self.width - 1 or y == 0 or
- y == self.height - 1 or generator.bounded(0, 40) == 0):
- column.append('#')
- else:
- column.append('.')
- self.map.append(column)
-
- def build_machine(self):
- machine = QStateMachine(self)
-
- input_state = Custom(machine, self)
- # this line sets the status
- self.status = 'hello!'
- # however this line does not
- input_state.assignProperty(self, 'status', 'Move the rogue with 2, 4, 6, and 8')
-
- machine.setInitialState(input_state)
- machine.start()
-
- transition = MovementTransition(self)
- input_state.addTransition(transition)
-
- quit_state = QState(machine)
- quit_state.assignProperty(self, 'status', 'Really quit(y/n)?')
-
- yes_transition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Y)
- self._final_state = QFinalState(machine)
- yes_transition.setTargetState(self._final_state)
- quit_state.addTransition(yes_transition)
-
- no_transition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_N)
- no_transition.setTargetState(input_state)
- quit_state.addTransition(no_transition)
-
- quit_transition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Q)
- quit_transition.setTargetState(quit_state)
- input_state.addTransition(quit_transition)
-
- machine.setInitialState(input_state)
- machine.finished.connect(qApp.quit)
- machine.start()
-
- def sizeHint(self):
- metrics = QFontMetrics(self.font())
- return QSize(metrics.horizontalAdvance('X') * self.width,
- metrics.height() * (self.height + 1))
-
- def paintEvent(self, event):
- metrics = QFontMetrics(self.font())
- with QPainter(self) as painter:
- font_height = metrics.height()
- font_width = metrics.horizontalAdvance('X')
-
- painter.fillRect(self.rect(), Qt.black)
- painter.setPen(Qt.white)
-
- y_pos = font_height
- painter.drawText(QPoint(0, y_pos), self.status)
- for y in range(self.height):
- y_pos += font_height
- x_pos = 0
- for x in range(self.width):
- if y == self.pY and x == self.pX:
- x_pos += font_width
- continue
- painter.drawText(QPoint(x_pos, y_pos), self.map[x][y])
- x_pos += font_width
- painter.drawText(QPoint(self.pX * font_width, (self.pY + 2) * font_height), '@')
-
- def move_player(self, direction):
- if direction == self.left:
- if self.map[self.pX - 1][self.pY] != '#':
- self.pX -= 1
- elif direction == self.right:
- if self.map[self.pX + 1][self.pY] != '#':
- self.pX += 1
- elif direction == self.Up:
- if self.map[self.pX][self.pY - 1] != '#':
- self.pY -= 1
- elif direction == self.down:
- if self.map[self.pX][self.pY + 1] != '#':
- self.pY += 1
- self.repaint()
-
- def get_status(self):
- return self._status_str
-
- def set_status(self, status):
- self._status_str = status
- self.repaint()
- status = Property(str, get_status, set_status)
- Up = 0
- down = 1
- left = 2
- right = 3
- width = 35
- height = 20
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- main_win = MainWindow()
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/rogue/rogue.pyproject b/examples/widgets/state-machine/rogue/rogue.pyproject
deleted file mode 100644
index b8baf9802..000000000
--- a/examples/widgets/state-machine/rogue/rogue.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["rogue.py"]
-}
diff --git a/examples/widgets/state-machine/trafficlight/doc/trafficlight.png b/examples/widgets/state-machine/trafficlight/doc/trafficlight.png
deleted file mode 100644
index ec88a8e8b..000000000
--- a/examples/widgets/state-machine/trafficlight/doc/trafficlight.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/state-machine/trafficlight/doc/trafficlight.rst b/examples/widgets/state-machine/trafficlight/doc/trafficlight.rst
deleted file mode 100644
index 57d369465..000000000
--- a/examples/widgets/state-machine/trafficlight/doc/trafficlight.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-Traffic Light Example
-=====================
-
-The Traffic Light example shows how to use The State Machine Framework to
-implement the control flow of a traffic light.
-
-
-.. image:: trafficlight.png
- :width: 400
- :alt: Traffic Light Screenshot
diff --git a/examples/widgets/state-machine/trafficlight/trafficlight.py b/examples/widgets/state-machine/trafficlight/trafficlight.py
deleted file mode 100644
index 1e58384f9..000000000
--- a/examples/widgets/state-machine/trafficlight/trafficlight.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QTimer, Qt, Property, Slot
-from PySide6.QtGui import QPainter, QPalette
-from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget
-from PySide6.QtStateMachine import QFinalState, QState, QStateMachine
-
-
-class LightWidget(QWidget):
- def __init__(self, color):
- super().__init__()
- self.color = color
- self._on_val = False
-
- def is_on(self):
- return self._on_val
-
- def set_on(self, on):
- if self._on_val == on:
- return
- self._on_val = on
- self.update()
-
- @Slot()
- def turn_off(self):
- self.set_on(False)
-
- @Slot()
- def turn_on(self):
- self.set_on(True)
-
- def paintEvent(self, e):
- if not self._on_val:
- return
- with QPainter(self) as painter:
- painter.setRenderHint(QPainter.Antialiasing)
- painter.setBrush(self.color)
- painter.drawEllipse(0, 0, self.width(), self.height())
-
- on = Property(bool, is_on, set_on)
-
-
-class TrafficLightWidget(QWidget):
- def __init__(self):
- super().__init__()
- vbox = QVBoxLayout(self)
- self._red_light = LightWidget(Qt.red)
- vbox.addWidget(self._red_light)
- self._yellow_light = LightWidget(Qt.yellow)
- vbox.addWidget(self._yellow_light)
- self._green_light = LightWidget(Qt.green)
- vbox.addWidget(self._green_light)
- pal = QPalette()
- pal.setColor(QPalette.Window, Qt.black)
- self.setPalette(pal)
- self.setAutoFillBackground(True)
-
-
-def create_light_state(light, duration, parent=None):
- light_state = QState(parent)
- timer = QTimer(light_state)
- timer.setInterval(duration)
- timer.setSingleShot(True)
- timing = QState(light_state)
- timing.entered.connect(light.turn_on)
- timing.entered.connect(timer.start)
- timing.exited.connect(light.turn_off)
- done = QFinalState(light_state)
- timing.addTransition(timer.timeout, done)
- light_state.setInitialState(timing)
- return light_state
-
-
-class TrafficLight(QWidget):
- def __init__(self):
- super().__init__()
- vbox = QVBoxLayout(self)
- widget = TrafficLightWidget()
- vbox.addWidget(widget)
- vbox.setContentsMargins(0, 0, 0, 0)
-
- machine = QStateMachine(self)
- red_going_yellow = create_light_state(widget._red_light, 1000)
- red_going_yellow.setObjectName('redGoingYellow')
- yellow_going_green = create_light_state(widget._red_light, 1000)
- yellow_going_green.setObjectName('yellowGoingGreen')
- red_going_yellow.addTransition(red_going_yellow.finished,
- yellow_going_green)
- green_going_yellow = create_light_state(widget._yellow_light, 3000)
- green_going_yellow.setObjectName('greenGoingYellow')
- yellow_going_green.addTransition(yellow_going_green.finished,
- green_going_yellow)
- yellow_going_red = create_light_state(widget._green_light, 1000)
- yellow_going_red.setObjectName('yellowGoingRed')
- green_going_yellow.addTransition(green_going_yellow.finished,
- yellow_going_red)
- yellow_going_red.addTransition(yellow_going_red.finished,
- red_going_yellow)
-
- machine.addState(red_going_yellow)
- machine.addState(yellow_going_green)
- machine.addState(green_going_yellow)
- machine.addState(yellow_going_red)
- machine.setInitialState(red_going_yellow)
- machine.start()
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- widget = TrafficLight()
- widget.resize(110, 300)
- widget.show()
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/trafficlight/trafficlight.pyproject b/examples/widgets/state-machine/trafficlight/trafficlight.pyproject
deleted file mode 100644
index 912472693..000000000
--- a/examples/widgets/state-machine/trafficlight/trafficlight.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["trafficlight.py"]
-}
diff --git a/examples/widgets/state-machine/twowaybutton/twowaybutton.py b/examples/widgets/state-machine/twowaybutton/twowaybutton.py
deleted file mode 100644
index 35a582f93..000000000
--- a/examples/widgets/state-machine/twowaybutton/twowaybutton.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtWidgets import QApplication, QPushButton
-from PySide6.QtStateMachine import QState, QStateMachine
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- button = QPushButton()
- machine = QStateMachine()
-
- off = QState()
- off.assignProperty(button, 'text', 'Off')
- off.setObjectName('off')
-
- on = QState()
- on.setObjectName('on')
- on.assignProperty(button, 'text', 'On')
-
- off.addTransition(button.clicked, on)
- on.addTransition(button.clicked, off)
-
- machine.addState(off)
- machine.addState(on)
- machine.setInitialState(off)
- machine.start()
- button.resize(100, 50)
- button.show()
- sys.exit(app.exec())
diff --git a/examples/widgets/state-machine/twowaybutton/twowaybutton.pyproject b/examples/widgets/state-machine/twowaybutton/twowaybutton.pyproject
deleted file mode 100644
index 223a51e32..000000000
--- a/examples/widgets/state-machine/twowaybutton/twowaybutton.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["twowaybutton.py"]
-}
diff --git a/examples/widgets/tools/regularexpression/regularexpression.py b/examples/widgets/tools/regularexpression/regularexpression.py
index fca24f617..261e26196 100644
--- a/examples/widgets/tools/regularexpression/regularexpression.py
+++ b/examples/widgets/tools/regularexpression/regularexpression.py
@@ -12,8 +12,6 @@ from regularexpressiondialog import RegularExpressionDialog
from PySide6.QtWidgets import QApplication
-import re
-
if __name__ == "__main__":
app = QApplication(sys.argv)
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.py b/examples/widgets/tools/regularexpression/regularexpressiondialog.py
index 9ebf8a65d..2d2bb2bb7 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.py
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.py
@@ -5,14 +5,15 @@ import re
import logging
from PySide6.QtCore import (QMargins, QRegularExpression, QRegularExpressionMatch,
- QRegularExpressionMatchIterator, Qt, Slot,)
+ QRegularExpressionMatchIterator, Qt, Slot,)
from PySide6.QtGui import (QAction, QColor, QContextMenuEvent, QFontDatabase,
- QGuiApplication, QIcon, QPalette,)
+ QGuiApplication, QIcon, QPalette,)
from PySide6.QtWidgets import (QCheckBox, QComboBox, QDialog, QFormLayout,
- QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QPlainTextEdit,
- QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,)
+ QFrame, QGridLayout, QHBoxLayout, QLabel,
+ QLineEdit, QPlainTextEdit, QSpinBox,
+ QTreeWidget, QTreeWidgetItem, QVBoxLayout,
+ QWidget)
-from PySide6.QtGui import QClipboard
def rawStringLiteral(pattern: str) -> str:
pattern = 'r"' + pattern
@@ -21,8 +22,8 @@ def rawStringLiteral(pattern: str) -> str:
def patternToCode(pattern: str) -> str:
- pattern = pattern.replace(f"\\", f"\\\\")
- pattern = pattern.replace(f'"', f'\\"')
+ pattern = pattern.replace("\\", "\\\\")
+ pattern = pattern.replace('"', '\\"')
pattern = '"' + pattern
pattern = pattern + '"'
return pattern
@@ -31,7 +32,7 @@ def patternToCode(pattern: str) -> str:
def codeToPattern(code: str) -> str:
try:
- new_code = code[0]
+ _ = code[0]
except IndexError:
logging.warning("code is empty")
return code
@@ -43,7 +44,7 @@ def codeToPattern(code: str) -> str:
if code_characters[index] == '\\':
del code_characters[index]
code_characters_size -= 1
- index +=1
+ index += 1
code = "".join(code_characters)
if code.startswith('"') and code.endswith('"'):
@@ -76,6 +77,7 @@ class PatternLineEdit(QLineEdit):
self.copyToCodeAction.triggered.connect(self.copyToCode)
self.pasteFromCodeAction.triggered.connect(self.pasteFromCode)
+ @Slot()
def escapeSelection(self):
selection = self.selectedText()
selection_start = self.selectionStart()
@@ -85,13 +87,15 @@ class PatternLineEdit(QLineEdit):
t = (
t[: selection_start]
+ escapedSelection
- + t[selection_start + len(selection) :]
+ + t[selection_start + len(selection):]
)
self.setText(t)
+ @Slot()
def copyToCode(self):
QGuiApplication.clipboard().setText(patternToCode(self.text()))
+ @Slot()
def pasteFromCode(self):
self.setText(codeToPattern(QGuiApplication.clipboard().text()))
@@ -165,6 +169,7 @@ class RegularExpressionDialog(QDialog):
self.palette.setColor(QPalette.Text, color)
widget.setPalette(self.palette)
+ @Slot()
def refresh(self):
self.setUpdatesEnabled(False)
self.pattern = self.patternLineEdit.text()
@@ -324,23 +329,20 @@ class RegularExpressionDialog(QDialog):
self.patternOptionsCheckBoxLayout = QGridLayout()
gridRow = 0
- self.patternOptionsCheckBoxLayout.addWidget(self.caseInsensitiveOptionCheckBox, gridRow, \
- 1)
- self.patternOptionsCheckBoxLayout.addWidget(self.dotMatchesEverythingOptionCheckBox, gridRow\
- ,2)
+ self.patternOptionsCheckBoxLayout.addWidget(self.caseInsensitiveOptionCheckBox, gridRow, 1)
+ self.patternOptionsCheckBoxLayout.addWidget(
+ self.dotMatchesEverythingOptionCheckBox, gridRow, 2)
gridRow = gridRow + 1
- self.patternOptionsCheckBoxLayout.addWidget(self.multilineOptionCheckBox, gridRow, \
- 1)
- self.patternOptionsCheckBoxLayout.addWidget(self.extendedPatternSyntaxOptionCheckBox, gridRow \
- , 2)
+ self.patternOptionsCheckBoxLayout.addWidget(self.multilineOptionCheckBox, gridRow, 1)
+ self.patternOptionsCheckBoxLayout.addWidget(
+ self.extendedPatternSyntaxOptionCheckBox, gridRow, 2)
gridRow = gridRow + 1
- self.patternOptionsCheckBoxLayout.addWidget(self.invertedGreedinessOptionCheckBox, gridRow,\
- 1)
- self.patternOptionsCheckBoxLayout.addWidget(self.dontCaptureOptionCheckBox, gridRow,\
- 2)
+ self.patternOptionsCheckBoxLayout.addWidget(
+ self.invertedGreedinessOptionCheckBox, gridRow, 1)
+ self.patternOptionsCheckBoxLayout.addWidget(self.dontCaptureOptionCheckBox, gridRow, 2)
gridRow = gridRow + 1
- self.patternOptionsCheckBoxLayout.addWidget(self.useUnicodePropertiesOptionCheckBox, gridRow,\
- 1)
+ self.patternOptionsCheckBoxLayout.addWidget(
+ self.useUnicodePropertiesOptionCheckBox, gridRow, 1)
form_layout.addRow("Pattern options:", self.patternOptionsCheckBoxLayout)
diff --git a/examples/widgets/tutorials/addressbook/part1.py b/examples/widgets/tutorials/addressbook/part1.py
index e26206d8f..648ddea46 100644
--- a/examples/widgets/tutorials/addressbook/part1.py
+++ b/examples/widgets/tutorials/addressbook/part1.py
@@ -5,9 +5,8 @@
import sys
from PySide6.QtCore import Qt
-from PySide6.QtWidgets import (QApplication, QGridLayout,
- QLabel, QGridLayout, QLineEdit, QTextEdit,
- QWidget)
+from PySide6.QtWidgets import (QApplication, QGridLayout, QLabel, QLineEdit,
+ QTextEdit, QWidget)
class AddressBook(QWidget):
diff --git a/examples/widgets/tutorials/addressbook/part2.py b/examples/widgets/tutorials/addressbook/part2.py
index ccc6139ab..3c0eb451d 100644
--- a/examples/widgets/tutorials/addressbook/part2.py
+++ b/examples/widgets/tutorials/addressbook/part2.py
@@ -4,9 +4,9 @@
import sys
-from PySide6.QtCore import Qt, Signal, Slot
-from PySide6.QtWidgets import (QApplication, QDialog, QGridLayout,
- QHBoxLayout, QLabel, QLineEdit,
+from PySide6.QtCore import Qt
+from PySide6.QtWidgets import (QApplication, QGridLayout,
+ QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
QVBoxLayout, QWidget)
@@ -102,17 +102,16 @@ class AddressBook(QWidget):
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
if not self.contacts:
diff --git a/examples/widgets/tutorials/addressbook/part3.py b/examples/widgets/tutorials/addressbook/part3.py
index 5365c1ae0..611796f5e 100644
--- a/examples/widgets/tutorials/addressbook/part3.py
+++ b/examples/widgets/tutorials/addressbook/part3.py
@@ -4,8 +4,8 @@
import sys
-from PySide6.QtCore import Qt, Signal, Slot
-from PySide6.QtWidgets import (QApplication, QDialog, QGridLayout,
+from PySide6.QtCore import Qt, Slot
+from PySide6.QtWidgets import (QApplication, QGridLayout,
QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
QVBoxLayout, QWidget)
@@ -110,22 +110,22 @@ class AddressBook(QWidget):
self._submit_button.show()
self._cancel_button.show()
+ @Slot()
def submit_contact(self):
name = self._name_line.text()
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
if not self.contacts:
@@ -143,6 +143,7 @@ class AddressBook(QWidget):
self._submit_button.hide()
self._cancel_button.hide()
+ @Slot()
def cancel(self):
self._name_line.setText(self._old_name)
self._address_text.setText(self._old_address)
@@ -162,6 +163,7 @@ class AddressBook(QWidget):
self._submit_button.hide()
self._cancel_button.hide()
+ @Slot()
def next(self):
name = self._name_line.text()
it = iter(self.contacts)
@@ -179,6 +181,7 @@ class AddressBook(QWidget):
self._name_line.setText(next_name)
self._address_text.setText(next_address)
+ @Slot()
def previous(self):
name = self._name_line.text()
diff --git a/examples/widgets/tutorials/addressbook/part4.py b/examples/widgets/tutorials/addressbook/part4.py
index 0b1edb054..95f31d46c 100644
--- a/examples/widgets/tutorials/addressbook/part4.py
+++ b/examples/widgets/tutorials/addressbook/part4.py
@@ -4,8 +4,8 @@
import sys
-from PySide6.QtCore import Qt, Signal, Slot
-from PySide6.QtWidgets import (QApplication, QDialog, QGridLayout,
+from PySide6.QtCore import Qt, Slot
+from PySide6.QtWidgets import (QApplication, QGridLayout,
QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
QVBoxLayout, QWidget)
@@ -105,6 +105,7 @@ class AddressBook(QWidget):
self.setLayout(main_layout)
self.setWindowTitle("Simple Address Book")
+ @Slot()
def add_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
@@ -114,72 +115,76 @@ class AddressBook(QWidget):
self.update_interface(self.AddingMode)
+ @Slot()
def edit_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
self.update_interface(self.EditingMode)
+ @Slot()
def submit_contact(self):
name = self._name_line.text()
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if self._current_mode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._current_mode == self.EditingMode:
if self._old_name != name:
if name not in self.contacts:
QMessageBox.information(self, "Edit Successful",
- f'"{self.oldName}" has been edited in your address book.')
+ f'"{self.oldName}" has been edited in your '
+ 'address book.')
del self.contacts[self._old_name]
self.contacts[name] = address
else:
QMessageBox.information(self, "Edit Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._old_address != address:
QMessageBox.information(self, "Edit Successful",
- f'"{name}" has been edited in your address book.')
+ f'"{name}" has been edited in your address book.')
self.contacts[name] = address
self.update_interface(self.NavigationMode)
+ @Slot()
def cancel(self):
self._name_line.setText(self._old_name)
self._address_text.setText(self._old_address)
self.update_interface(self.NavigationMode)
+ @Slot()
def remove_contact(self):
name = self._name_line.text()
- address = self._address_text.toPlainText()
if name in self.contacts:
button = QMessageBox.question(self, "Confirm Remove",
- f'Are you sure you want to remove "{name}"?',
- QMessageBox.Yes | QMessageBox.No)
+ f'Are you sure you want to remove "{name}"?',
+ QMessageBox.Yes | QMessageBox.No)
if button == QMessageBox.Yes:
self.previous()
del self.contacts[name]
QMessageBox.information(self, "Remove Successful",
- f'"{name}" has been removed from your address book.')
+ f'"{name}" has been removed from your address book.')
self.update_interface(self.NavigationMode)
+ @Slot()
def next(self):
name = self._name_line.text()
it = iter(self.contacts)
@@ -197,6 +202,7 @@ class AddressBook(QWidget):
self._name_line.setText(next_name)
self._address_text.setText(next_address)
+ @Slot()
def previous(self):
name = self._name_line.text()
diff --git a/examples/widgets/tutorials/addressbook/part5.py b/examples/widgets/tutorials/addressbook/part5.py
index 48404c95d..1e9c05862 100644
--- a/examples/widgets/tutorials/addressbook/part5.py
+++ b/examples/widgets/tutorials/addressbook/part5.py
@@ -2,10 +2,9 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import pickle
import sys
-from PySide6.QtCore import Qt, Signal, Slot
+from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import (QApplication, QDialog, QGridLayout,
QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
@@ -112,6 +111,7 @@ class AddressBook(QWidget):
self.setLayout(main_layout)
self.setWindowTitle("Simple Address Book")
+ @Slot()
def add_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
@@ -121,72 +121,76 @@ class AddressBook(QWidget):
self.update_interface(self.AddingMode)
+ @Slot()
def edit_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
self.update_interface(self.EditingMode)
+ @Slot()
def submit_contact(self):
name = self._name_line.text()
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if self._current_mode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._current_mode == self.EditingMode:
if self._old_name != name:
if name not in self.contacts:
QMessageBox.information(self, "Edit Successful",
- f'"{self.oldName}" has been edited in your address book.')
+ f'"{self.oldName}" has been edited in your '
+ 'address book.')
del self.contacts[self._old_name]
self.contacts[name] = address
else:
QMessageBox.information(self, "Edit Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._old_address != address:
QMessageBox.information(self, "Edit Successful",
- f'"{name}" has been edited in your address book.')
+ f'"{name}" has been edited in your address book.')
self.contacts[name] = address
self.update_interface(self.NavigationMode)
+ @Slot()
def cancel(self):
self._name_line.setText(self._old_name)
self._address_text.setText(self._old_address)
self.update_interface(self.NavigationMode)
+ @Slot()
def remove_contact(self):
name = self._name_line.text()
- address = self._address_text.toPlainText()
if name in self.contacts:
button = QMessageBox.question(self, "Confirm Remove",
- f'Are you sure you want to remove "{name}"?',
- QMessageBox.Yes | QMessageBox.No)
+ f'Are you sure you want to remove "{name}"?',
+ QMessageBox.Yes | QMessageBox.No)
if button == QMessageBox.Yes:
self.previous()
del self.contacts[name]
QMessageBox.information(self, "Remove Successful",
- f'"{name}" has been removed from your address book.')
+ f'"{name}" has been removed from your address book.')
self.update_interface(self.NavigationMode)
+ @Slot()
def next(self):
name = self._name_line.text()
it = iter(self.contacts)
@@ -204,6 +208,7 @@ class AddressBook(QWidget):
self._name_line.setText(next_name)
self._address_text.setText(next_address)
+ @Slot()
def previous(self):
name = self._name_line.text()
@@ -237,7 +242,7 @@ class AddressBook(QWidget):
self._address_text.setText(self.contacts[contact_name])
else:
QMessageBox.information(self, "Contact Not Found",
- f'Sorry, "{contact_name}" is not in your address book.')
+ f'Sorry, "{contact_name}" is not in your address book.')
return
self.update_interface(self.NavigationMode)
@@ -305,8 +310,7 @@ class FindDialog(QDialog):
text = self._line_edit.text()
if not text:
- QMessageBox.information(self, "Empty Field",
- "Please enter a name.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name.")
return
else:
self._find_text = text
diff --git a/examples/widgets/tutorials/addressbook/part6.py b/examples/widgets/tutorials/addressbook/part6.py
index 9070a34da..d11298fb9 100644
--- a/examples/widgets/tutorials/addressbook/part6.py
+++ b/examples/widgets/tutorials/addressbook/part6.py
@@ -5,7 +5,7 @@
import pickle
import sys
-from PySide6.QtCore import QFile, QIODevice, QTextStream, Qt, Signal, Slot
+from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import (QApplication, QDialog, QFileDialog,
QGridLayout, QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
@@ -122,6 +122,7 @@ class AddressBook(QWidget):
self.setLayout(main_layout)
self.setWindowTitle("Simple Address Book")
+ @Slot()
def add_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
@@ -131,72 +132,76 @@ class AddressBook(QWidget):
self.update_interface(self.AddingMode)
+ @Slot()
def edit_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
self.update_interface(self.EditingMode)
+ @Slot()
def submit_contact(self):
name = self._name_line.text()
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if self._current_mode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._current_mode == self.EditingMode:
if self._old_name != name:
if name not in self.contacts:
QMessageBox.information(self, "Edit Successful",
- f'"{self.oldName}" has been edited in your address book.')
+ f'"{self.oldName}" has been edited in your '
+ 'address book.')
del self.contacts[self._old_name]
self.contacts[name] = address
else:
QMessageBox.information(self, "Edit Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._old_address != address:
QMessageBox.information(self, "Edit Successful",
- f'"{name}" has been edited in your address book.')
+ f'"{name}" has been edited in your address book.')
self.contacts[name] = address
self.update_interface(self.NavigationMode)
+ @Slot()
def cancel(self):
self._name_line.setText(self._old_name)
self._address_text.setText(self._old_address)
self.update_interface(self.NavigationMode)
+ @Slot()
def remove_contact(self):
name = self._name_line.text()
- address = self._address_text.toPlainText()
if name in self.contacts:
button = QMessageBox.question(self, "Confirm Remove",
- f'Are you sure you want to remove "{name}"?',
- QMessageBox.Yes | QMessageBox.No)
+ f'Are you sure you want to remove "{name}"?',
+ QMessageBox.Yes | QMessageBox.No)
if button == QMessageBox.Yes:
self.previous()
del self.contacts[name]
QMessageBox.information(self, "Remove Successful",
- f'"{name}" has been removed from your address book.')
+ f'"{name}" has been removed from your address book.')
self.update_interface(self.NavigationMode)
+ @Slot()
def next(self):
name = self._name_line.text()
it = iter(self.contacts)
@@ -214,6 +219,7 @@ class AddressBook(QWidget):
self._name_line.setText(next_name)
self._address_text.setText(next_address)
+ @Slot()
def previous(self):
name = self._name_line.text()
@@ -247,7 +253,7 @@ class AddressBook(QWidget):
self._address_text.setText(self.contacts[contact_name])
else:
QMessageBox.information(self, "Contact Not Found",
- f'Sorry, "{contact_name}" is not in your address book.')
+ f'Sorry, "{contact_name}" is not in your address book.')
return
self.update_interface(self.NavigationMode)
@@ -297,8 +303,8 @@ class AddressBook(QWidget):
def save_to_file(self):
fileName, _ = QFileDialog.getSaveFileName(self,
- "Save Address Book", '',
- "Address Book (*.abk);;All Files (*)")
+ "Save Address Book", '',
+ "Address Book (*.abk);;All Files (*)")
if not fileName:
return
@@ -307,7 +313,7 @@ class AddressBook(QWidget):
out_file = open(str(fileName), 'wb')
except IOError:
QMessageBox.information(self, "Unable to open file",
- f'There was an error opening "{fileName}"')
+ f'There was an error opening "{fileName}"')
return
pickle.dump(self.contacts, out_file)
@@ -315,8 +321,8 @@ class AddressBook(QWidget):
def load_from_file(self):
fileName, _ = QFileDialog.getOpenFileName(self,
- "Open Address Book", '',
- "Address Book (*.abk);;All Files (*)")
+ "Open Address Book", '',
+ "Address Book (*.abk);;All Files (*)")
if not fileName:
return
@@ -325,7 +331,7 @@ class AddressBook(QWidget):
in_file = open(str(fileName), 'rb')
except IOError:
QMessageBox.information(self, "Unable to open file",
- f'There was an error opening "{fileName}"')
+ f'There was an error opening "{fileName}"')
return
self.contacts = pickle.load(in_file)
@@ -333,8 +339,7 @@ class AddressBook(QWidget):
if len(self.contacts) == 0:
QMessageBox.information(self, "No contacts in file",
- "The file you are attempting to open contains no "
- "contacts.")
+ "The file you are attempting to open contains no contacts.")
else:
for name, address in self.contacts:
self._name_line.setText(name)
@@ -368,8 +373,7 @@ class FindDialog(QDialog):
text = self._line_edit.text()
if not text:
- QMessageBox.information(self, "Empty Field",
- "Please enter a name.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name.")
return
self._find_text = text
diff --git a/examples/widgets/tutorials/addressbook/part7.py b/examples/widgets/tutorials/addressbook/part7.py
index 2fc7a8d1c..3829c003d 100644
--- a/examples/widgets/tutorials/addressbook/part7.py
+++ b/examples/widgets/tutorials/addressbook/part7.py
@@ -5,7 +5,7 @@
import pickle
import sys
-from PySide6.QtCore import QFile, QIODevice, QTextStream, Qt, Signal, Slot
+from PySide6.QtCore import QFile, QIODevice, QTextStream, Qt, Slot
from PySide6.QtWidgets import (QApplication, QDialog, QFileDialog,
QGridLayout, QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QPushButton, QTextEdit,
@@ -128,6 +128,7 @@ class AddressBook(QWidget):
self.setLayout(main_layout)
self.setWindowTitle("Simple Address Book")
+ @Slot()
def add_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
@@ -137,72 +138,76 @@ class AddressBook(QWidget):
self.update_interface(self.AddingMode)
+ @Slot()
def edit_contact(self):
self._old_name = self._name_line.text()
self._old_address = self._address_text.toPlainText()
self.update_interface(self.EditingMode)
+ @Slot()
def submit_contact(self):
name = self._name_line.text()
address = self._address_text.toPlainText()
if name == "" or address == "":
- QMessageBox.information(self, "Empty Field",
- "Please enter a name and address.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name and address.")
return
if self._current_mode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
- f'"{name}" has been added to your address book.')
+ f'"{name}" has been added to your address book.')
else:
QMessageBox.information(self, "Add Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._current_mode == self.EditingMode:
if self._old_name != name:
if name not in self.contacts:
QMessageBox.information(self, "Edit Successful",
- f'"{self.oldName}" has been edited in your address book.')
+ f'"{self.oldName}" has been edited in your '
+ 'address book.')
del self.contacts[self._old_name]
self.contacts[name] = address
else:
QMessageBox.information(self, "Edit Unsuccessful",
- f'Sorry, "{name}" is already in your address book.')
+ f'Sorry, "{name}" is already in your address book.')
return
elif self._old_address != address:
QMessageBox.information(self, "Edit Successful",
- f'"{name}" has been edited in your address book.')
+ f'"{name}" has been edited in your address book.')
self.contacts[name] = address
self.update_interface(self.NavigationMode)
+ @Slot()
def cancel(self):
self._name_line.setText(self._old_name)
self._address_text.setText(self._old_address)
self.update_interface(self.NavigationMode)
+ @Slot()
def remove_contact(self):
name = self._name_line.text()
- address = self._address_text.toPlainText()
if name in self.contacts:
button = QMessageBox.question(self, "Confirm Remove",
- f'Are you sure you want to remove "{name}"?',
- QMessageBox.Yes | QMessageBox.No)
+ f'Are you sure you want to remove "{name}"?',
+ QMessageBox.Yes | QMessageBox.No)
if button == QMessageBox.Yes:
self.previous()
del self.contacts[name]
QMessageBox.information(self, "Remove Successful",
- f'"{name}" has been removed from your address book.')
+ f'"{name}" has been removed from your address book.')
self.update_interface(self.NavigationMode)
+ @Slot()
def next(self):
name = self._name_line.text()
it = iter(self.contacts)
@@ -220,6 +225,7 @@ class AddressBook(QWidget):
self._name_line.setText(next_name)
self._address_text.setText(next_address)
+ @Slot()
def previous(self):
name = self._name_line.text()
@@ -253,7 +259,7 @@ class AddressBook(QWidget):
self._address_text.setText(self.contacts[contact_name])
else:
QMessageBox.information(self, "Contact Not Found",
- f'Sorry, "{contact_name}" is not in your address book.')
+ f'Sorry, "{contact_name}" is not in your address book.')
return
self.update_interface(self.NavigationMode)
@@ -306,8 +312,8 @@ class AddressBook(QWidget):
def save_to_file(self):
fileName, _ = QFileDialog.getSaveFileName(self,
- "Save Address Book", '',
- "Address Book (*.abk);;All Files (*)")
+ "Save Address Book", '',
+ "Address Book (*.abk);;All Files (*)")
if not fileName:
return
@@ -316,7 +322,7 @@ class AddressBook(QWidget):
out_file = open(str(fileName), 'wb')
except IOError:
QMessageBox.information(self, "Unable to open file",
- f'There was an error opening "{fileName}"')
+ f'There was an error opening "{fileName}"')
return
pickle.dump(self.contacts, out_file)
@@ -324,8 +330,8 @@ class AddressBook(QWidget):
def load_from_file(self):
fileName, _ = QFileDialog.getOpenFileName(self,
- "Open Address Book", '',
- "Address Book (*.abk);;All Files (*)")
+ "Open Address Book", '',
+ "Address Book (*.abk);;All Files (*)")
if not fileName:
return
@@ -334,7 +340,7 @@ class AddressBook(QWidget):
in_file = open(str(fileName), 'rb')
except IOError:
QMessageBox.information(self, "Unable to open file",
- f'There was an error opening "{fileName}"')
+ f'There was an error opening "{fileName}"')
return
self.contacts = pickle.load(in_file)
@@ -342,8 +348,7 @@ class AddressBook(QWidget):
if len(self.contacts) == 0:
QMessageBox.information(self, "No contacts in file",
- "The file you are attempting to open contains no "
- "contacts.")
+ "The file you are attempting to open contains no contacts.")
else:
for name, address in self.contacts:
self._name_line.setText(name)
@@ -365,7 +370,7 @@ class AddressBook(QWidget):
last_name = ''
file_name = QFileDialog.getSaveFileName(self, "Export Contact",
- '', "vCard Files (*.vcf);;All Files (*)")[0]
+ '', "vCard Files (*.vcf);;All Files (*)")[0]
if not file_name:
return
@@ -373,8 +378,7 @@ class AddressBook(QWidget):
out_file = QFile(file_name)
if not out_file.open(QIODevice.WriteOnly):
- QMessageBox.information(self, "Unable to open file",
- out_file.errorString())
+ QMessageBox.information(self, "Unable to open file", out_file.errorString())
return
out_s = QTextStream(out_file)
@@ -392,7 +396,7 @@ class AddressBook(QWidget):
out_s << 'END:VCARD' << '\n'
QMessageBox.information(self, "Export Successful",
- f'"{name}" has been exported as a vCard.')
+ f'"{name}" has been exported as a vCard.')
class FindDialog(QDialog):
@@ -420,8 +424,7 @@ class FindDialog(QDialog):
text = self._line_edit.text()
if not text:
- QMessageBox.information(self, "Empty Field",
- "Please enter a name.")
+ QMessageBox.information(self, "Empty Field", "Please enter a name.")
return
self._find_text = text
diff --git a/examples/widgets/tutorials/cannon/t10.py b/examples/widgets/tutorials/cannon/t10.py
index db080f050..8649bb562 100644
--- a/examples/widgets/tutorials/cannon/t10.py
+++ b/examples/widgets/tutorials/cannon/t10.py
@@ -6,7 +6,7 @@
import sys
-from PySide6.QtCore import QRect, Qt, Signal, Slot
+from PySide6.QtCore import QRect, Qt, Signal, Slot, qWarning
from PySide6.QtGui import QColor, QFont, QPainter, QPalette
from PySide6.QtWidgets import (QApplication, QGridLayout, QLCDNumber,
QPushButton, QSlider, QVBoxLayout, QWidget)
@@ -43,8 +43,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -113,7 +113,7 @@ class MyWidget(QWidget):
quit = QPushButton("&Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange()
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/cannon/t11.py b/examples/widgets/tutorials/cannon/t11.py
index c7a4ffbd4..fbfd2481d 100644
--- a/examples/widgets/tutorials/cannon/t11.py
+++ b/examples/widgets/tutorials/cannon/t11.py
@@ -7,7 +7,7 @@
import sys
import math
-from PySide6.QtCore import QPoint, QRect, QTimer, Qt, Signal, Slot
+from PySide6.QtCore import QPoint, QRect, QTimer, Qt, Signal, Slot, qWarning
from PySide6.QtGui import QColor, QFont, QPainter, QPalette, QRegion
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout,
QLCDNumber, QPushButton, QSlider,
@@ -45,8 +45,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -175,7 +175,7 @@ class MyWidget(QWidget):
quit = QPushButton("&Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange()
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/cannon/t12.py b/examples/widgets/tutorials/cannon/t12.py
index 3887bbf2e..749c24684 100644
--- a/examples/widgets/tutorials/cannon/t12.py
+++ b/examples/widgets/tutorials/cannon/t12.py
@@ -8,7 +8,7 @@ import sys
import math
import random
-from PySide6.QtCore import QPoint, QRect, QTime, QTimer, Qt, Signal, Slot
+from PySide6.QtCore import QPoint, QRect, QTime, QTimer, Qt, Signal, Slot, qWarning
from PySide6.QtGui import QColor, QFont, QPainter, QPalette, QRegion
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout,
QLabel, QLCDNumber, QPushButton, QSlider,
@@ -62,8 +62,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -226,7 +226,7 @@ class MyWidget(QWidget):
quit = QPushButton("&Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange("ANGLE")
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/cannon/t13.py b/examples/widgets/tutorials/cannon/t13.py
index ddd5341da..f9a771d15 100644
--- a/examples/widgets/tutorials/cannon/t13.py
+++ b/examples/widgets/tutorials/cannon/t13.py
@@ -8,8 +8,8 @@ import sys
import math
import random
-from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, Qt, SIGNAL, SLOT,
- Signal, Slot)
+from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, Qt,
+ Signal, Slot, qWarning)
from PySide6.QtGui import QColor, QFont, QPainter, QPalette, QRegion
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QLabel,
QLCDNumber, QPushButton, QSizePolicy, QSlider,
@@ -64,8 +64,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -259,7 +259,7 @@ class GameBoard(QWidget):
quit = QPushButton("&Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange("ANGLE")
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/cannon/t14.py b/examples/widgets/tutorials/cannon/t14.py
index aa0f8876b..3c94408f3 100644
--- a/examples/widgets/tutorials/cannon/t14.py
+++ b/examples/widgets/tutorials/cannon/t14.py
@@ -8,10 +8,10 @@ import sys
import math
import random
-from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, QSize, Qt, SIGNAL,
- SLOT, Signal, Slot)
+from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, QSize, Qt,
+ Signal, Slot, qWarning)
from PySide6.QtGui import (QColor, QFont, QKeySequence, QPainter, QPalette,
- QShortcut, QRegion)
+ QShortcut, QRegion, QTransform)
from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QHBoxLayout,
QLabel, QLCDNumber, QPushButton, QSizePolicy,
QSlider, QVBoxLayout, QWidget)
@@ -65,8 +65,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -174,7 +174,8 @@ class CannonField(QWidget):
self._auto_shoot_timer.stop()
self.hit.emit()
self.can_shoot.emit(True)
- elif shot_r.x() > self.width() or shot_r.y() > self.height() or shot_r.intersects(self.barrier_rect()):
+ elif (shot_r.x() > self.width() or shot_r.y() > self.height()
+ or shot_r.intersects(self.barrier_rect())):
self._auto_shoot_timer.stop()
self.missed.emit()
self.can_shoot.emit(True)
@@ -301,7 +302,7 @@ class GameBoard(QWidget):
quit = QPushButton("&Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange("ANGLE")
angle.set_range(5, 70)
@@ -341,7 +342,7 @@ class GameBoard(QWidget):
QShortcut(QKeySequence(Qt.Key_Enter), self, self.fire)
QShortcut(QKeySequence(Qt.Key_Return), self, self.fire)
- QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self, self.close)
+ QShortcut(QKeySequence(Qt.CTRL | Qt.Key_Q), self, self.close)
top_layout = QHBoxLayout()
top_layout.addWidget(shoot)
diff --git a/examples/widgets/tutorials/cannon/t2.py b/examples/widgets/tutorials/cannon/t2.py
index 57326ac37..d3adba396 100644
--- a/examples/widgets/tutorials/cannon/t2.py
+++ b/examples/widgets/tutorials/cannon/t2.py
@@ -6,9 +6,8 @@
import sys
-from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, Qt)
from PySide6.QtGui import QFont
-from PySide6.QtWidgets import (QApplication, QPushButton)
+from PySide6.QtWidgets import QApplication, QPushButton
if __name__ == '__main__':
diff --git a/examples/widgets/tutorials/cannon/t4.py b/examples/widgets/tutorials/cannon/t4.py
index ba0ebc41b..37a2dc9dd 100644
--- a/examples/widgets/tutorials/cannon/t4.py
+++ b/examples/widgets/tutorials/cannon/t4.py
@@ -20,7 +20,7 @@ class MyWidget(QWidget):
self.quit.setGeometry(62, 40, 75, 30)
self.quit.setFont(QFont("Times", 18, QFont.Bold))
- self.quit.clicked.connect(qApp.quit)
+ self.quit.clicked.connect(qApp.quit) # noqa: F821
if __name__ == '__main__':
diff --git a/examples/widgets/tutorials/cannon/t5.py b/examples/widgets/tutorials/cannon/t5.py
index 42faeed01..ed5d085f8 100644
--- a/examples/widgets/tutorials/cannon/t5.py
+++ b/examples/widgets/tutorials/cannon/t5.py
@@ -25,7 +25,7 @@ class MyWidget(QWidget):
slider.setRange(0, 99)
slider.setValue(0)
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
slider.valueChanged.connect(lcd.display)
layout = QVBoxLayout(self)
diff --git a/examples/widgets/tutorials/cannon/t6.py b/examples/widgets/tutorials/cannon/t6.py
index 1cc2906f2..ea2e044e6 100644
--- a/examples/widgets/tutorials/cannon/t6.py
+++ b/examples/widgets/tutorials/cannon/t6.py
@@ -33,7 +33,7 @@ class MyWidget(QWidget):
quit = QPushButton("Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
layout = QVBoxLayout(self)
layout.addWidget(quit)
diff --git a/examples/widgets/tutorials/cannon/t7.py b/examples/widgets/tutorials/cannon/t7.py
index 51128e6c7..1175107b8 100644
--- a/examples/widgets/tutorials/cannon/t7.py
+++ b/examples/widgets/tutorials/cannon/t7.py
@@ -46,7 +46,7 @@ class MyWidget(QWidget):
quit = QPushButton("Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
previous_range = None
diff --git a/examples/widgets/tutorials/cannon/t8.py b/examples/widgets/tutorials/cannon/t8.py
index c887a36a6..9bb5516b8 100644
--- a/examples/widgets/tutorials/cannon/t8.py
+++ b/examples/widgets/tutorials/cannon/t8.py
@@ -6,7 +6,7 @@
import sys
-from PySide6.QtCore import Signal, Slot, Qt
+from PySide6.QtCore import Signal, Slot, Qt, qWarning
from PySide6.QtGui import QColor, QFont, QPainter, QPalette
from PySide6.QtWidgets import (QApplication, QGridLayout, QLCDNumber,
QPushButton, QSlider, QVBoxLayout, QWidget)
@@ -43,8 +43,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning("LCDRange.setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -88,7 +88,7 @@ class MyWidget(QWidget):
quit = QPushButton("Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange()
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/cannon/t9.py b/examples/widgets/tutorials/cannon/t9.py
index 2526d1573..7cdda4e7b 100644
--- a/examples/widgets/tutorials/cannon/t9.py
+++ b/examples/widgets/tutorials/cannon/t9.py
@@ -6,7 +6,7 @@
import sys
-from PySide6.QtCore import QRect, Qt, Signal, Slot
+from PySide6.QtCore import QRect, Qt, Signal, Slot, qWarning
from PySide6.QtGui import QColor, QFont, QPainter, QPalette
from PySide6.QtWidgets import (QApplication, QGridLayout, QLCDNumber,
QPushButton, QSlider, QVBoxLayout, QWidget)
@@ -43,8 +43,8 @@ class LCDRange(QWidget):
def set_range(self, minValue, maxValue):
if minValue < 0 or maxValue > 99 or minValue > maxValue:
qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n"
- "\tRange must be 0..99\n"
- "\tand minValue must not be greater than maxValue")
+ "\tRange must be 0..99\n"
+ "\tand minValue must not be greater than maxValue")
return
self.slider.setRange(minValue, maxValue)
@@ -94,7 +94,7 @@ class MyWidget(QWidget):
quit = QPushButton("Quit")
quit.setFont(QFont("Times", 18, QFont.Bold))
- quit.clicked.connect(qApp.quit)
+ quit.clicked.connect(qApp.quit) # noqa: F821
angle = LCDRange()
angle.set_range(5, 70)
diff --git a/examples/widgets/tutorials/modelview/1_readonly.py b/examples/widgets/tutorials/modelview/1_readonly.py
new file mode 100644
index 000000000..9dc923260
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/1_readonly.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QAbstractTableModel, Qt
+from PySide6.QtWidgets import QApplication, QTableView
+
+"""PySide6 port of the widgets/tutorials/modelview/1_readonly example from Qt v6.x"""
+
+
+#! [1]
+class MyModel(QAbstractTableModel):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ def rowCount(self, parent=None):
+ return 2
+
+ def columnCount(self, parent=None):
+ return 3
+
+ def data(self, index, role=Qt.DisplayRole):
+ if role == Qt.DisplayRole:
+ row = index.row() + 1
+ column = index.column() + 1
+ return f"Row{row}, Column{column}"
+ return None
+#! [1]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ table_view = QTableView()
+ my_model = MyModel()
+ table_view.setModel(my_model)
+ table_view.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/2_formatting.py b/examples/widgets/tutorials/modelview/2_formatting.py
new file mode 100644
index 000000000..f39ec462c
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/2_formatting.py
@@ -0,0 +1,65 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QAbstractTableModel, Qt
+from PySide6.QtGui import QBrush, QFont
+from PySide6.QtWidgets import QApplication, QTableView
+
+"""PySide6 port of the widgets/tutorials/modelview/2_formatting example from Qt v6.x"""
+
+
+class MyModel(QAbstractTableModel):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ def rowCount(self, parent=None):
+ return 2
+
+ def columnCount(self, parent=None):
+ return 3
+
+#! [1]
+ def data(self, index, role=Qt.DisplayRole):
+ row = index.row()
+ col = index.column()
+ # generate a log message when this method gets called
+ print(f"row {row}, col{col}, role {role}")
+
+ if role == Qt.DisplayRole:
+ if row == 0 and col == 1:
+ return "<--left"
+ if row == 1 and col == 1:
+ return "right-->"
+ return f"Row{row}, Column{col + 1}"
+
+ elif role == Qt.FontRole:
+ if row == 0 and col == 0: # change font only for cell(0,0)
+ bold_font = QFont()
+ bold_font.setBold(True)
+ return bold_font
+
+ elif role == Qt.BackgroundRole:
+ if row == 1 and col == 2: # change background only for cell(1,2)
+ return QBrush(Qt.red)
+
+ elif role == Qt.TextAlignmentRole:
+ if row == 1 and col == 1: # change text alignment only for cell(1,1)
+ return Qt.AlignRight | Qt.AlignVCenter
+
+ elif role == Qt.CheckStateRole:
+ if row == 1 and col == 0: # add a checkbox to cell(1,0)
+ return Qt.Checked
+
+ return None
+#! [1]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ table_view = QTableView()
+ my_model = MyModel()
+ table_view.setModel(my_model)
+ table_view.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel.py b/examples/widgets/tutorials/modelview/3_changingmodel.py
new file mode 100644
index 000000000..2148ec5d3
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/3_changingmodel.py
@@ -0,0 +1,53 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QAbstractTableModel, QTime, QTimer, Qt, Slot
+from PySide6.QtWidgets import QApplication, QTableView
+
+"""PySide6 port of the widgets/tutorials/modelview/3_changingmodel example from Qt v6.x"""
+
+
+class MyModel(QAbstractTableModel):
+#! [1]
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._timer = QTimer(self)
+ self._timer.setInterval(1000)
+ self._timer.timeout.connect(self.timer_hit)
+ self._timer.start()
+#! [1]
+
+ def rowCount(self, parent=None):
+ return 2
+
+ def columnCount(self, parent=None):
+ return 3
+
+#! [2]
+ def data(self, index, role=Qt.DisplayRole):
+ row = index.row()
+ col = index.column()
+ if role == Qt.DisplayRole and row == 0 and col == 0:
+ return QTime.currentTime().toString()
+ return None
+#! [2]
+
+#! [3]
+ @Slot()
+ def timer_hit(self):
+ # we identify the top left cell
+ top_left = self.createIndex(0, 0)
+ # emit a signal to make the view reread identified data
+ self.dataChanged.emit(top_left, top_left, [Qt.DisplayRole])
+#! [3]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ table_view = QTableView()
+ my_model = MyModel()
+ table_view.setModel(my_model)
+ table_view.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/4_headers.py b/examples/widgets/tutorials/modelview/4_headers.py
new file mode 100644
index 000000000..3feef17bf
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/4_headers.py
@@ -0,0 +1,43 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QAbstractTableModel, Qt
+from PySide6.QtWidgets import QApplication, QTableView
+
+"""PySide6 port of the widgets/tutorials/modelview/4_headers example from Qt v6.x"""
+
+
+class MyModel(QAbstractTableModel):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ def rowCount(self, parent=None):
+ return 2
+
+ def columnCount(self, parent=None):
+ return 3
+
+ def data(self, index, role=Qt.DisplayRole):
+ if role == Qt.DisplayRole:
+ row = index.row() + 1
+ column = index.column() + 1
+ return f"Row{row}, Column{column}"
+ return None
+
+#! [1]
+ def headerData(self, section, orientation, role):
+ if role == Qt.DisplayRole and orientation == Qt.Horizontal:
+ return ["first", "second", "third"][section]
+ return None
+#! [1]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ table_view = QTableView()
+ my_model = MyModel()
+ table_view.setModel(my_model)
+ table_view.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/5_edit.py b/examples/widgets/tutorials/modelview/5_edit.py
new file mode 100644
index 000000000..1a4481fc9
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/5_edit.py
@@ -0,0 +1,73 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+from itertools import chain
+
+from PySide6.QtCore import QAbstractTableModel, Qt, Signal, Slot
+from PySide6.QtWidgets import QApplication, QMainWindow, QTableView
+
+"""PySide6 port of the widgets/tutorials/modelview/5_edit example from Qt v6.x"""
+
+
+COLS = 3
+ROWS = 2
+
+
+class MyModel(QAbstractTableModel):
+
+ editCompleted = Signal(str)
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._grid_data = [["" for y in range(COLS)] for x in range(ROWS)]
+
+ def rowCount(self, parent=None):
+ return ROWS
+
+ def columnCount(self, parent=None):
+ return COLS
+
+ def data(self, index, role=Qt.DisplayRole):
+ if role == Qt.DisplayRole and self.checkIndex(index):
+ return self._grid_data[index.row()][index.column()]
+ return None
+
+#! [1]
+ def setData(self, index, value, role):
+ if role != Qt.EditRole or not self.checkIndex(index):
+ return False
+ # save value from editor to member m_gridData
+ self._grid_data[index.row()][index.column()] = value
+ # for presentation purposes only: build and emit a joined string
+ result = " ".join(chain(*self._grid_data))
+ self.editCompleted.emit(result)
+ return True
+#! [1]
+
+#! [2]
+ def flags(self, index):
+ return Qt.ItemIsEditable | super().flags(index)
+#! [2]
+
+
+class MainWindow(QMainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._table_view = QTableView(self)
+ self.setCentralWidget(self._table_view)
+ my_model = MyModel(self)
+ self._table_view.setModel(my_model)
+ # transfer changes to the model to the window title
+ my_model.editCompleted.connect(self.show_window_title)
+
+ @Slot(str)
+ def show_window_title(self, title):
+ self.setWindowTitle(title)
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ w = MainWindow()
+ w.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/6_treeview.py b/examples/widgets/tutorials/modelview/6_treeview.py
new file mode 100644
index 000000000..cac3c6d53
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/6_treeview.py
@@ -0,0 +1,42 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtGui import QStandardItem, QStandardItemModel
+from PySide6.QtWidgets import QApplication, QMainWindow, QTreeView
+
+"""PySide6 port of the widgets/tutorials/modelview/6_treeview example from Qt v6.x"""
+
+
+#! [1]
+class MainWindow(QMainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._standard_model = QStandardItemModel(self)
+ self._tree_view = QTreeView(self)
+ self.setCentralWidget(self._tree_view)
+
+ prepared_row = self.prepare_row("first", "second", "third")
+ item = self._standard_model.invisibleRootItem()
+ # adding a row to the invisible root item produces a root element
+ item.appendRow(prepared_row)
+
+ second_row = self.prepare_row("111", "222", "333")
+ # adding a row to an item starts a subtree
+ prepared_row[0].appendRow(second_row)
+
+ self._tree_view.setModel(self._standard_model)
+ self._tree_view.expandAll()
+
+ def prepare_row(self, first, second, third):
+ return [QStandardItem(first), QStandardItem(second),
+ QStandardItem(third)]
+#! [1]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ w = MainWindow()
+ w.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/7_selections.py b/examples/widgets/tutorials/modelview/7_selections.py
new file mode 100644
index 000000000..c879d8f67
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/7_selections.py
@@ -0,0 +1,71 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QItemSelection, Qt, Slot
+from PySide6.QtGui import QStandardItem, QStandardItemModel
+from PySide6.QtWidgets import QApplication, QMainWindow, QTreeView
+
+"""PySide6 port of the widgets/tutorials/modelview/7_selections example from Qt v6.x"""
+
+
+#! [1]
+class MainWindow(QMainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._standard_model = QStandardItemModel(self)
+ self._tree_view = QTreeView(self)
+ self.setCentralWidget(self._tree_view)
+
+ # defining a couple of items
+ root_node = self._standard_model.invisibleRootItem()
+
+ america_item = QStandardItem("America")
+ mexico_item = QStandardItem("Canada")
+ usa_item = QStandardItem("USA")
+ boston_item = QStandardItem("Boston")
+ europe_item = QStandardItem("Europe")
+ italy_item = QStandardItem("Italy")
+ rome_item = QStandardItem("Rome")
+ verona_item = QStandardItem("Verona")
+
+ # building up the hierarchy
+ root_node.appendRow(america_item)
+ root_node.appendRow(europe_item)
+ america_item.appendRow(mexico_item)
+ america_item.appendRow(usa_item)
+ usa_item.appendRow(boston_item)
+ europe_item.appendRow(italy_item)
+ italy_item.appendRow(rome_item)
+ italy_item.appendRow(verona_item)
+
+ self._tree_view.setModel(self._standard_model)
+ self._tree_view.expandAll()
+
+ # selection changes shall trigger a slot
+ selection_model = self._tree_view.selectionModel()
+ selection_model.selectionChanged.connect(self.selection_changed_slot)
+#! [1]
+
+#! [2]
+ @Slot(QItemSelection, QItemSelection)
+ def selection_changed_slot(self, new_selection, old_selection):
+ # get the text of the selected item
+ index = self._tree_view.selectionModel().currentIndex()
+ selected_text = index.data(Qt.DisplayRole)
+ # find out the hierarchy level of the selected item
+ hierarchy_level = 1
+ seek_root = index
+ while seek_root.parent().isValid():
+ seek_root = seek_root.parent()
+ hierarchy_level += 1
+ self.setWindowTitle(f"{selected_text}, Level {hierarchy_level}")
+#! [2]
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ w = MainWindow()
+ w.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/tutorials/modelview/doc/modelview.rst b/examples/widgets/tutorials/modelview/doc/modelview.rst
new file mode 100644
index 000000000..017f78de1
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/doc/modelview.rst
@@ -0,0 +1,4 @@
+Model View Tutorial Examples
+============================
+
+Example code for the Model View Tutorial.
diff --git a/examples/widgets/tutorials/modelview/modelview.pyproject b/examples/widgets/tutorials/modelview/modelview.pyproject
new file mode 100644
index 000000000..3bbe9d47a
--- /dev/null
+++ b/examples/widgets/tutorials/modelview/modelview.pyproject
@@ -0,0 +1,9 @@
+{
+ "files": ["1_readonly.py",
+ "2_formatting.py",
+ "3_changingmodel.py",
+ "4_headers.py",
+ "5_edit.py",
+ "6_treeview.py",
+ "7_selections.py"]
+}
diff --git a/examples/widgets/widgets/charactermap/charactermap.pyproject b/examples/widgets/widgets/charactermap/charactermap.pyproject
new file mode 100644
index 000000000..c2b2c2068
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/charactermap.pyproject
@@ -0,0 +1,4 @@
+{
+ "files": ["main.py", "characterwidget.py", "fontinfodialog.py",
+ "mainwindow.py"]
+}
diff --git a/examples/widgets/widgets/charactermap/characterwidget.py b/examples/widgets/widgets/charactermap/characterwidget.py
new file mode 100644
index 000000000..0f01f9684
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/characterwidget.py
@@ -0,0 +1,133 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from textwrap import dedent
+
+from PySide6.QtCore import QSize, Qt, Slot, Signal
+from PySide6.QtGui import (QBrush, QFont, QFontDatabase, QFontMetrics,
+ QPainter, QPen)
+from PySide6.QtWidgets import QToolTip, QWidget
+
+COLUMNS = 16
+
+
+class CharacterWidget(QWidget):
+
+ character_selected = Signal(str)
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ self._display_font = QFont()
+ self._last_key = -1
+ self._square_size = int(0)
+
+ self.calculate_square_size()
+ self.setMouseTracking(True)
+
+ @Slot(QFont)
+ def update_font(self, font):
+ self._display_font.setFamily(font.family())
+ self.calculate_square_size()
+ self.adjustSize()
+ self.update()
+
+ @Slot(str)
+ def update_size(self, fontSize):
+ self._display_font.setPointSize(int(fontSize))
+ self.calculate_square_size()
+ self.adjustSize()
+ self.update()
+
+ @Slot(str)
+ def update_style(self, fontStyle):
+ old_strategy = self._display_font.styleStrategy()
+ self._display_font = QFontDatabase.font(self._display_font.family(),
+ fontStyle,
+ self._display_font.pointSize())
+ self._display_font.setStyleStrategy(old_strategy)
+ self.calculate_square_size()
+ self.adjustSize()
+ self.update()
+
+ @Slot(bool)
+ def update_font_merging(self, enable):
+ if enable:
+ self._display_font.setStyleStrategy(QFont.PreferDefault)
+ else:
+ self._display_font.setStyleStrategy(QFont.NoFontMerging)
+ self.adjustSize()
+ self.update()
+
+ def calculate_square_size(self):
+ h = QFontMetrics(self._display_font, self).height()
+ self._square_size = max(16, 4 + h)
+
+ def sizeHint(self):
+ return QSize(COLUMNS * self._square_size,
+ (65536 / COLUMNS) * self._square_size)
+
+ def _unicode_from_pos(self, point):
+ row = int(point.y() / self._square_size)
+ return row * COLUMNS + int(point.x() / self._square_size)
+
+ def mouseMoveEvent(self, event):
+ widget_position = self.mapFromGlobal(event.globalPosition().toPoint())
+ key = self._unicode_from_pos(widget_position)
+ c = chr(key)
+ family = self._display_font.family()
+ text = dedent(f'''
+ <p>Character: <span style="font-size: 24pt; font-family: {family}">
+ {c}</span><p>Value: 0x{key:x}
+ ''')
+ QToolTip.showText(event.globalPosition().toPoint(), text, self)
+
+ def mousePressEvent(self, event):
+ if event.button() == Qt.LeftButton:
+ self._last_key = self._unicode_from_pos(event.position().toPoint())
+ if self._last_key != -1:
+ c = chr(self._last_key)
+ self.character_selected.emit(f"{c}")
+ self.update()
+ else:
+ super().mousePressEvent(event)
+
+ def paintEvent(self, event):
+ with QPainter(self) as painter:
+ self.render(event, painter)
+
+ def render(self, event, painter):
+ painter = QPainter(self)
+ painter.fillRect(event.rect(), QBrush(Qt.white))
+ painter.setFont(self._display_font)
+ redraw_rect = event.rect()
+ begin_row = int(redraw_rect.top() / self._square_size)
+ end_row = int(redraw_rect.bottom() / self._square_size)
+ begin_column = int(redraw_rect.left() / self._square_size)
+ end_column = int(redraw_rect.right() / self._square_size)
+ painter.setPen(QPen(Qt.gray))
+ for row in range(begin_row, end_row + 1):
+ for column in range(begin_column, end_column + 1):
+ x = int(column * self._square_size)
+ y = int(row * self._square_size)
+ painter.drawRect(x, y, self._square_size, self._square_size)
+
+ font_metrics = QFontMetrics(self._display_font)
+ painter.setPen(QPen(Qt.black))
+ for row in range(begin_row, end_row + 1):
+ for column in range(begin_column, end_column + 1):
+ key = int(row * COLUMNS + column)
+ painter.setClipRect(column * self._square_size,
+ row * self._square_size,
+ self._square_size, self._square_size)
+
+ if key == self._last_key:
+ painter.fillRect(column * self._square_size + 1,
+ row * self._square_size + 1,
+ self._square_size, self._square_size, QBrush(Qt.red))
+
+ text = chr(key)
+ painter.drawText(column * self._square_size + (self._square_size / 2)
+ - font_metrics.horizontalAdvance(text) / 2,
+ row * self._square_size + 4 + font_metrics.ascent(),
+ text)
diff --git a/examples/widgets/widgets/charactermap/doc/charactermap.rst b/examples/widgets/widgets/charactermap/doc/charactermap.rst
new file mode 100644
index 000000000..1a38615c4
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/doc/charactermap.rst
@@ -0,0 +1,8 @@
+Character Map Example
+=====================
+
+The example displays an array of characters which the user can click on
+to enter text in a line edit. The contents of the line edit can then be
+copied into the clipboard, and pasted into other applications. The
+purpose behind this sort of tool is to allow users to enter characters
+that may be unavailable or difficult to locate on their keyboards.
diff --git a/examples/widgets/widgets/charactermap/fontinfodialog.py b/examples/widgets/widgets/charactermap/fontinfodialog.py
new file mode 100644
index 000000000..aa874884f
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/fontinfodialog.py
@@ -0,0 +1,47 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from PySide6.QtCore import Qt, qVersion, qFuzzyCompare
+from PySide6.QtGui import QGuiApplication, QFontDatabase
+from PySide6.QtWidgets import (QDialog, QDialogButtonBox,
+ QPlainTextEdit, QVBoxLayout)
+
+
+def _format_font(font):
+ family = font.family()
+ size = font.pointSizeF()
+ return f"{family}, {size}pt"
+
+
+class FontInfoDialog(QDialog):
+
+ def __init__(self, parent):
+ super().__init__(parent)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ main_layout = QVBoxLayout(self)
+ text_edit = QPlainTextEdit(self.text(), self)
+ text_edit.setReadOnly(True)
+ text_edit.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
+ main_layout.addWidget(text_edit)
+ button_box = QDialogButtonBox(QDialogButtonBox.Close, self)
+ button_box.rejected.connect(self.reject)
+ main_layout.addWidget(button_box)
+
+ def text(self):
+ default_font = QFontDatabase.systemFont(QFontDatabase.GeneralFont)
+ fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
+ title_font = QFontDatabase.systemFont(QFontDatabase.TitleFont)
+ smallest_readable_font = QFontDatabase.systemFont(QFontDatabase.SmallestReadableFont)
+
+ v = qVersion()
+ platform = QGuiApplication.platformName()
+ dpi = self.logicalDpiX()
+ dpr = self.devicePixelRatio()
+ text = f"Qt {v} on {platform}, {dpi}DPI"
+ if not qFuzzyCompare(dpr, float(1)):
+ text += f", device pixel ratio: {dpr}"
+ text += ("\n\nDefault font : " + _format_font(default_font)
+ + "\nFixed font : " + _format_font(fixed_font)
+ + "\nTitle font : " + _format_font(title_font)
+ + "\nSmallest font: " + _format_font(smallest_readable_font))
+ return text
diff --git a/examples/widgets/widgets/charactermap/main.py b/examples/widgets/widgets/charactermap/main.py
new file mode 100644
index 000000000..e84a1d8af
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/main.py
@@ -0,0 +1,17 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtWidgets import QApplication
+
+from mainwindow import MainWindow
+
+"""PySide6 port of the widgets/widgets/ charactermap example from Qt6"""
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ window = MainWindow()
+ window.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/widgets/charactermap/mainwindow.py b/examples/widgets/widgets/charactermap/mainwindow.py
new file mode 100644
index 000000000..d79285def
--- /dev/null
+++ b/examples/widgets/widgets/charactermap/mainwindow.py
@@ -0,0 +1,167 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+from PySide6.QtCore import Qt, QSignalBlocker, Slot
+from PySide6.QtGui import QGuiApplication, QClipboard, QFont, QFontDatabase
+from PySide6.QtWidgets import (QCheckBox, QComboBox, QFontComboBox,
+ QHBoxLayout, QLabel, QLineEdit, QMainWindow,
+ QPushButton, QScrollArea,
+ QVBoxLayout, QWidget)
+
+from characterwidget import CharacterWidget
+from fontinfodialog import FontInfoDialog
+
+
+class MainWindow(QMainWindow):
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ self._character_widget = CharacterWidget()
+ self._filter_combo = QComboBox()
+ self._style_combo = QComboBox()
+ self._size_combo = QComboBox()
+ self._font_combo = QFontComboBox()
+ self._line_edit = QLineEdit()
+ self._scroll_area = QScrollArea()
+ self._font_merging = QCheckBox()
+
+ file_menu = self.menuBar().addMenu("File")
+ file_menu.addAction("Quit", self.close)
+ help_menu = self.menuBar().addMenu("Help")
+ help_menu.addAction("Show Font Info", self.show_info)
+ help_menu.addAction("About &Qt", qApp.aboutQt) # noqa: F821
+
+ central_widget = QWidget()
+
+ self._filter_label = QLabel("Filter:")
+ self._filter_combo = QComboBox()
+ self._filter_combo.addItem("All", int(QFontComboBox.AllFonts.value))
+ self._filter_combo.addItem("Scalable", int(QFontComboBox.ScalableFonts.value))
+ self._filter_combo.addItem("Monospaced", int(QFontComboBox.MonospacedFonts.value))
+ self._filter_combo.addItem("Proportional", int(QFontComboBox.ProportionalFonts.value))
+ self._filter_combo.setCurrentIndex(0)
+ self._filter_combo.currentIndexChanged.connect(self.filter_changed)
+
+ self._font_label = QLabel("Font:")
+ self._font_combo = QFontComboBox()
+ self._size_label = QLabel("Size:")
+ self._size_combo = QComboBox()
+ self._style_label = QLabel("Style:")
+ self._style_combo = QComboBox()
+ self._font_merging_label = QLabel("Automatic Font Merging:")
+ self._font_merging = QCheckBox()
+ self._font_merging.setChecked(True)
+
+ self._scroll_area = QScrollArea()
+ self._character_widget = CharacterWidget()
+ self._scroll_area.setWidget(self._character_widget)
+ self.find_styles(self._font_combo.currentFont())
+ self.find_sizes(self._font_combo.currentFont())
+
+ self._line_edit = QLineEdit()
+ self._line_edit.setClearButtonEnabled(True)
+ self._clipboard_button = QPushButton("To clipboard")
+ self._font_combo.currentFontChanged.connect(self.find_styles)
+ self._font_combo.currentFontChanged.connect(self.find_sizes)
+ self._font_combo.currentFontChanged.connect(self._character_widget.update_font)
+ self._size_combo.currentTextChanged.connect(self._character_widget.update_size)
+ self._style_combo.currentTextChanged.connect(self._character_widget.update_style)
+ self._character_widget.character_selected.connect(self.insert_character)
+
+ self._clipboard_button.clicked.connect(self.update_clipboard)
+ self._font_merging.toggled.connect(self._character_widget.update_font_merging)
+
+ controls_layout = QHBoxLayout()
+ controls_layout.addWidget(self._filter_label)
+ controls_layout.addWidget(self._filter_combo, 1)
+ controls_layout.addWidget(self._font_label)
+ controls_layout.addWidget(self._font_combo, 1)
+ controls_layout.addWidget(self._size_label)
+ controls_layout.addWidget(self._size_combo, 1)
+ controls_layout.addWidget(self._style_label)
+ controls_layout.addWidget(self._style_combo, 1)
+ controls_layout.addWidget(self._font_merging_label)
+ controls_layout.addWidget(self._font_merging, 1)
+ controls_layout.addStretch(1)
+
+ line_layout = QHBoxLayout()
+ line_layout.addWidget(self._line_edit, 1)
+ line_layout.addSpacing(12)
+ line_layout.addWidget(self._clipboard_button)
+
+ central_layout = QVBoxLayout(central_widget)
+ central_layout.addLayout(controls_layout)
+ central_layout.addWidget(self._scroll_area, 1)
+ central_layout.addSpacing(4)
+ central_layout.addLayout(line_layout)
+
+ self.setCentralWidget(central_widget)
+ self.setWindowTitle("Character Map")
+
+ @Slot(QFont)
+ def find_styles(self, font):
+ current_item = self._style_combo.currentText()
+ self._style_combo.clear()
+ styles = QFontDatabase.styles(font.family())
+ for style in styles:
+ self._style_combo.addItem(style)
+
+ style_index = self._style_combo.findText(current_item)
+
+ if style_index == -1:
+ self._style_combo.setCurrentIndex(0)
+ else:
+ self._style_combo.setCurrentIndex(style_index)
+
+ @Slot(int)
+ def filter_changed(self, f):
+ filter = QFontComboBox.FontFilter(self._filter_combo.itemData(f))
+ self._font_combo.setFontFilters(filter)
+ count = self._font_combo.count()
+ self.statusBar().showMessage(f"{count} font(s) found")
+
+ @Slot(QFont)
+ def find_sizes(self, font):
+ current_size = self._size_combo.currentText()
+ with QSignalBlocker(self._size_combo):
+ # sizeCombo signals are now blocked until end of scope
+ self._size_combo.clear()
+
+ style = QFontDatabase.styleString(font)
+ if QFontDatabase.isSmoothlyScalable(font.family(), style):
+ sizes = QFontDatabase.standardSizes()
+ for size in sizes:
+ self._size_combo.addItem(f"{size}")
+ self._size_combo.setEditable(True)
+ else:
+ sizes = QFontDatabase.smoothSizes(font.family(), style)
+ for size in sizes:
+ self._size_combo.addItem(f"{size}")
+ self._size_combo.setEditable(False)
+
+ size_index = self._size_combo.findText(current_size)
+
+ if size_index == -1:
+ self._size_combo.setCurrentIndex(max(0, self._size_combo.count() / 3))
+ else:
+ self._size_combo.setCurrentIndex(size_index)
+
+ @Slot(str)
+ def insert_character(self, character):
+ self._line_edit.insert(character)
+
+ @Slot()
+ def update_clipboard(self):
+ clipboard = QGuiApplication.clipboard()
+ clipboard.setText(self._line_edit.text(), QClipboard.Clipboard)
+ clipboard.setText(self._line_edit.text(), QClipboard.Selection)
+
+ @Slot()
+ def show_info(self):
+ screen_geometry = self.screen().geometry()
+ dialog = FontInfoDialog(self)
+ dialog.setWindowTitle("Fonts")
+ dialog.setAttribute(Qt.WA_DeleteOnClose)
+ dialog.resize(screen_geometry.width() / 4, screen_geometry.height() / 4)
+ dialog.show()
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.py b/examples/widgets/widgets/digitalclock/digitalclock.py
new file mode 100644
index 000000000..f0030b356
--- /dev/null
+++ b/examples/widgets/widgets/digitalclock/digitalclock.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+import sys
+
+from PySide6.QtCore import QTime, QTimer, Slot
+from PySide6.QtWidgets import QApplication, QLCDNumber
+
+
+class DigitalClock(QLCDNumber):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setSegmentStyle(QLCDNumber.Filled)
+ self.setDigitCount(8)
+
+ self.timer = QTimer(self)
+ self.timer.timeout.connect(self.show_time)
+ self.timer.start(1000)
+
+ self.show_time()
+
+ self.setWindowTitle("Digital Clock")
+ self.resize(250, 60)
+
+ @Slot()
+ def show_time(self):
+ time = QTime.currentTime()
+ text = time.toString("hh:mm:ss")
+
+ # Blinking effect
+ if (time.second() % 2) == 0:
+ text = text.replace(":", " ")
+
+ self.display(text)
+
+
+if __name__ == "__main__":
+
+ app = QApplication(sys.argv)
+ clock = DigitalClock()
+ clock.show()
+ sys.exit(app.exec())
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.pyproject b/examples/widgets/widgets/digitalclock/digitalclock.pyproject
new file mode 100644
index 000000000..03c3b6bb7
--- /dev/null
+++ b/examples/widgets/widgets/digitalclock/digitalclock.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["digitalclock.py"]
+}
diff --git a/examples/widgets/widgets/digitalclock/doc/digitalclock-screenshot.png b/examples/widgets/widgets/digitalclock/doc/digitalclock-screenshot.png
new file mode 100644
index 000000000..2234d7665
--- /dev/null
+++ b/examples/widgets/widgets/digitalclock/doc/digitalclock-screenshot.png
Binary files differ
diff --git a/examples/widgets/widgets/digitalclock/doc/digitalclock.rst b/examples/widgets/widgets/digitalclock/doc/digitalclock.rst
new file mode 100644
index 000000000..d13275d24
--- /dev/null
+++ b/examples/widgets/widgets/digitalclock/doc/digitalclock.rst
@@ -0,0 +1,14 @@
+Digital Clock Example
+=====================
+
+.. tags:: Android
+
+The Digital Clock example shows how to use QLCDNumber to display a number with
+LCD-like digits.
+
+.. image:: digitalclock-screenshot.png
+ :width: 400
+ :alt: Digital Clock Screenshot
+
+This example also demonstrates how QTimer can be used to update a widget at
+regular intervals.
diff --git a/examples/widgets/tetrix/doc/tetrix-screenshot.png b/examples/widgets/widgets/tetrix/doc/tetrix-screenshot.png
index 2c3dade39..2c3dade39 100644
--- a/examples/widgets/tetrix/doc/tetrix-screenshot.png
+++ b/examples/widgets/widgets/tetrix/doc/tetrix-screenshot.png
Binary files differ
diff --git a/examples/widgets/tetrix/doc/tetrix.rst b/examples/widgets/widgets/tetrix/doc/tetrix.rst
index 0749de9de..0749de9de 100644
--- a/examples/widgets/tetrix/doc/tetrix.rst
+++ b/examples/widgets/widgets/tetrix/doc/tetrix.rst
diff --git a/examples/widgets/tetrix/tetrix.py b/examples/widgets/widgets/tetrix/tetrix.py
index 49fd7c4ff..b5df2aa35 100644
--- a/examples/widgets/tetrix/tetrix.py
+++ b/examples/widgets/widgets/tetrix/tetrix.py
@@ -9,7 +9,7 @@ import random
import sys
from PySide6.QtCore import QBasicTimer, QSize, Qt, Signal, Slot
-from PySide6.QtGui import QColor, QPainter
+from PySide6.QtGui import QColor, QPainter, QPixmap
from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QLabel,
QLCDNumber, QPushButton, QWidget)
@@ -52,7 +52,7 @@ class TetrixWindow(QWidget):
start_button.clicked.connect(self.board.start)
pause_button.clicked.connect(self.board.pause)
- quit_button.clicked.connect(qApp.quit)
+ quit_button.clicked.connect(qApp.quit) # noqa: F821
self.board.score_changed.connect(score_lcd.display)
self.board.level_changed.connect(level_lcd.display)
self.board.lines_removed_changed.connect(lines_lcd.display)
@@ -134,12 +134,13 @@ class TetrixBoard(QFrame):
def sizeHint(self):
return QSize(TetrixBoard.board_width * 15 + self.frameWidth() * 2,
- TetrixBoard.board_height * 15 + self.frameWidth() * 2)
+ TetrixBoard.board_height * 15 + self.frameWidth() * 2)
def minimum_size_hint(self):
return QSize(TetrixBoard.board_width * 5 + self.frameWidth() * 2,
- TetrixBoard.board_height * 5 + self.frameWidth() * 2)
+ TetrixBoard.board_height * 5 + self.frameWidth() * 2)
+ @Slot()
def start(self):
if self._is_paused:
return
@@ -159,6 +160,7 @@ class TetrixBoard(QFrame):
self.new_piece()
self.timer.start(self.timeout_time(), self)
+ @Slot()
def pause(self):
if not self._is_started:
return
@@ -188,16 +190,17 @@ class TetrixBoard(QFrame):
shape = self.shape_at(j, TetrixBoard.board_height - i - 1)
if shape != Piece.NoShape:
self.draw_square(painter,
- rect.left() + j * self.square_width(),
- board_top + i * self.square_height(), shape)
+ rect.left() + j * self.square_width(),
+ board_top + i * self.square_height(), shape)
if self._cur_piece.shape() != Piece.NoShape:
for i in range(4):
x = self._cur_x + self._cur_piece.x(i)
y = self._cur_y - self._cur_piece.y(i)
self.draw_square(painter, rect.left() + x * self.square_width(),
- board_top + (TetrixBoard.board_height - y - 1) * self.square_height(),
- self._cur_piece.shape())
+ board_top
+ + (TetrixBoard.board_height - y - 1) * self.square_height(),
+ self._cur_piece.shape())
def keyPressEvent(self, event):
if not self._is_started or self._is_paused or self._cur_piece.shape() == Piece.NoShape:
@@ -232,7 +235,8 @@ class TetrixBoard(QFrame):
super(TetrixBoard, self).timerEvent(event)
def clear_board(self):
- self.board = [Piece.NoShape for i in range(TetrixBoard.board_height * TetrixBoard.board_width)]
+ self.board = [
+ Piece.NoShape for _ in range(TetrixBoard.board_height * TetrixBoard.board_width)]
def drop_down(self):
drop_height = 0
@@ -281,7 +285,7 @@ class TetrixBoard(QFrame):
if line_is_full:
num_full_lines += 1
- for k in range(TetrixBoard.board_height - 1):
+ for k in range(i, TetrixBoard.board_height - 1):
for j in range(TetrixBoard.board_width):
self.set_shape_at(j, k, self.shape_at(j, k + 1))
@@ -322,11 +326,11 @@ class TetrixBoard(QFrame):
with QPainter(pixmap) as painter:
painter.fillRect(pixmap.rect(), self.nextPieceLabel.palette().background())
- for int in range(4):
+ for i in range(4):
x = self._next_piece.x(i) - self._next_piece.min_x()
y = self._next_piece.y(i) - self._next_piece.min_y()
self.draw_square(painter, x * self.square_width(),
- y * self.square_height(), self._next_piece.shape())
+ y * self.square_height(), self._next_piece.shape())
self.nextPieceLabel.setPixmap(pixmap)
@@ -347,11 +351,10 @@ class TetrixBoard(QFrame):
def draw_square(self, painter, x, y, shape):
color_table = [0x000000, 0xCC6666, 0x66CC66, 0x6666CC,
- 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00]
+ 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00]
color = QColor(color_table[shape])
- painter.fillRect(x + 1, y + 1, self.square_width() - 2,
- self.square_height() - 2, color)
+ painter.fillRect(x + 1, y + 1, self.square_width() - 2, self.square_height() - 2, color)
painter.setPen(color.lighter())
painter.drawLine(x, y + self.square_height() - 1, x, y)
@@ -359,25 +362,25 @@ class TetrixBoard(QFrame):
painter.setPen(color.darker())
painter.drawLine(x + 1, y + self.square_height() - 1,
- x + self.square_width() - 1, y + self.square_height() - 1)
+ x + self.square_width() - 1, y + self.square_height() - 1)
painter.drawLine(x + self.square_width() - 1,
- y + self.square_height() - 1, x + self.square_width() - 1, y + 1)
+ y + self.square_height() - 1, x + self.square_width() - 1, y + 1)
class TetrixPiece(object):
coords_table = (
- ((0, 0), (0, 0), (0, 0), (0, 0)),
- ((0, -1), (0, 0), (-1, 0), (-1, 1)),
- ((0, -1), (0, 0), (1, 0), (1, 1)),
- ((0, -1), (0, 0), (0, 1), (0, 2)),
- ((-1, 0), (0, 0), (1, 0), (0, 1)),
- ((0, 0), (1, 0), (0, 1), (1, 1)),
- ((-1, -1), (0, -1), (0, 0), (0, 1)),
- ((1, -1), (0, -1), (0, 0), (0, 1))
+ ((0, 0), (0, 0), (0, 0), (0, 0)),
+ ((0, -1), (0, 0), (-1, 0), (-1, 1)),
+ ((0, -1), (0, 0), (1, 0), (1, 1)),
+ ((0, -1), (0, 0), (0, 1), (0, 2)),
+ ((-1, 0), (0, 0), (1, 0), (0, 1)),
+ ((0, 0), (1, 0), (0, 1), (1, 1)),
+ ((-1, -1), (0, -1), (0, 0), (0, 1)),
+ ((1, -1), (0, -1), (0, 0), (0, 1))
)
def __init__(self):
- self.coords = [[0,0] for _ in range(4)]
+ self.coords = [[0, 0] for _ in range(4)]
self._piece_shape = Piece.NoShape
self.set_shape(Piece.NoShape)
diff --git a/examples/widgets/tetrix/tetrix.pyproject b/examples/widgets/widgets/tetrix/tetrix.pyproject
index 75121ea64..75121ea64 100644
--- a/examples/widgets/tetrix/tetrix.pyproject
+++ b/examples/widgets/widgets/tetrix/tetrix.pyproject
diff --git a/examples/widgets/widgetsgallery/main.py b/examples/widgets/widgetsgallery/main.py
index 1b034d323..e40077a38 100644
--- a/examples/widgets/widgetsgallery/main.py
+++ b/examples/widgets/widgetsgallery/main.py
@@ -5,14 +5,11 @@
import sys
-from PySide6.QtCore import QCoreApplication, Qt
from PySide6.QtWidgets import QApplication
from widgetgallery import WidgetGallery
if __name__ == '__main__':
- QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
- QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication()
gallery = WidgetGallery()
gallery.show()
diff --git a/examples/widgets/widgetsgallery/widgetgallery.py b/examples/widgets/widgetsgallery/widgetgallery.py
index d96241106..d43ab26a5 100644
--- a/examples/widgets/widgetsgallery/widgetgallery.py
+++ b/examples/widgets/widgetsgallery/widgetgallery.py
@@ -3,13 +3,21 @@
import sys
-from PySide6.QtWidgets import *
+from PySide6.QtCore import (QDateTime, QDir, QLibraryInfo, QSysInfo, Qt,
+ QTimer, Slot, qVersion)
from PySide6.QtGui import (QCursor, QDesktopServices, QGuiApplication, QIcon,
QKeySequence, QShortcut, QStandardItem,
- QStandardItemModel, QScreen, QWindow)
-from PySide6.QtCore import (QDateTime, QDir, QLibraryInfo, QMetaObject,
- QSysInfo, QTextStream, QTimer, Qt, qVersion)
-
+ QStandardItemModel)
+from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox,
+ QCommandLinkButton, QDateTimeEdit, QDial,
+ QDialog, QDialogButtonBox, QFileSystemModel,
+ QGridLayout, QGroupBox, QHBoxLayout, QLabel,
+ QLineEdit, QListView, QMenu, QPlainTextEdit,
+ QProgressBar, QPushButton, QRadioButton,
+ QScrollBar, QSizePolicy, QSlider, QSpinBox,
+ QStyleFactory, QTableWidget, QTabWidget,
+ QTextBrowser, QTextEdit, QToolBox, QToolButton,
+ QTreeView, QVBoxLayout, QWidget)
POEM = """Twinkle, twinkle, little star,
How I wonder what you are.
@@ -156,8 +164,8 @@ class WidgetGallery(QDialog):
top_layout.addStretch(1)
top_layout.addWidget(disable_widgets_checkbox)
- dialog_buttonbox = QDialogButtonBox(QDialogButtonBox.Help |
- QDialogButtonBox.Close)
+ dialog_buttonbox = QDialogButtonBox(QDialogButtonBox.Help
+ | QDialogButtonBox.Close)
init_widget(dialog_buttonbox, "dialogButtonBox")
dialog_buttonbox.helpRequested.connect(launch_module_help)
dialog_buttonbox.rejected.connect(self.reject)
@@ -180,9 +188,11 @@ class WidgetGallery(QDialog):
self.windowHandle().screenChanged.connect(self.update_systeminfo)
self.update_systeminfo()
+ @Slot(str)
def change_style(self, style_name):
QApplication.setStyle(QStyleFactory.create(style_name))
+ @Slot()
def advance_progressbar(self):
cur_val = self._progress_bar.value()
max_val = self._progress_bar.maximum()
@@ -379,6 +389,7 @@ class WidgetGallery(QDialog):
timer.start(1000)
return result
+ @Slot()
def update_systeminfo(self):
"""Display system information"""
system_info = SYSTEMINFO.format(sys.version,
@@ -387,6 +398,7 @@ class WidgetGallery(QDialog):
screen_info(self))
self._systeminfo_textbrowser.setHtml(system_info)
+ @Slot()
def help_on_current_widget(self):
"""Display help on widget under mouse"""
w = QApplication.widgetAt(QCursor.pos(self.screen()))