From 13e7ef89e69d1856746a9bade228e3105c3910a5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Nov 2023 12:10:26 +0100 Subject: Examples: Fix some flake warnings Mostly spacing related. Change-Id: If0d5b25e1c60b7b216f970d1e57613f00bd04a37 Reviewed-by: Adrian Herrmann (cherry picked from commit ddc01a90175e90a7854be0d90bed25a902613e59) Reviewed-by: Qt Cherry-pick Bot --- examples/axcontainer/axviewer/axviewer.py | 2 +- examples/bluetooth/heartrate_game/heartrate_global.py | 1 + .../bluetooth/heartrate_server/heartrate_server.py | 2 +- examples/bluetooth/lowenergyscanner/device.py | 1 + examples/charts/chartthemes/main.py | 3 +-- examples/charts/donutbreakdown/donutbreakdown.py | 2 +- examples/charts/legend/legend.py | 3 ++- examples/charts/memoryusage/memoryusage.py | 2 +- examples/charts/modeldata/modeldata.py | 2 +- .../pointselectionandmarkers.py | 16 ++++++---------- examples/charts/pointselectionandmarkers/utilities.py | 10 ++++++++++ examples/corelib/settingseditor/settingseditor.py | 18 ++++++++++++------ examples/corelib/threads/mandelbrot.py | 4 ++-- examples/dbus/pingpong/ping.py | 2 +- examples/designer/taskmenuextension/tictactoeplugin.py | 2 +- examples/installer_test/hello.py | 2 +- examples/multimedia/audiooutput/audiooutput.py | 2 +- examples/multimedia/audiosource/audiosource.py | 1 + examples/multimedia/camera/videosettings.py | 1 - examples/multimedia/player/player.py | 2 +- .../blockingfortuneclient/blockingfortuneclient.py | 7 ++++--- .../threadedfortuneserver/threadedfortuneserver.py | 6 +++--- examples/networkauth/redditclient/redditmodel.py | 2 +- examples/networkauth/redditclient/redditwrapper.py | 3 ++- examples/opengl/contextinfo/contextinfo.py | 2 +- examples/opengl/threadedqopenglwidget/renderer.py | 2 +- .../extending-qml/chapter6-plugins/Charts/piechart.py | 1 + .../extending-qml/chapter6-plugins/Charts/pieslice.py | 1 + .../quick/models/objectlistmodel/objectlistmodel.py | 2 +- .../quick/models/stringlistmodel/stringlistmodel.py | 2 +- examples/serialbus/modbus/modbusclient/mainwindow.py | 2 +- examples/serialport/terminal/settingsdialog.py | 2 +- examples/spatialaudio/audiopanning/main.py | 2 +- examples/sql/books/bookdelegate.py | 1 - examples/utils/pyside_config.py | 2 +- .../webenginequick/nanobrowser/quicknanobrowser.py | 4 ++-- .../webenginewidgets/simplebrowser/downloadwidget.py | 1 - .../widgetsnanobrowser/widgetsnanobrowser.py | 2 +- .../widgets/animation/animatedtiles/animatedtiles.py | 4 ++-- examples/widgets/animation/easing/easing.py | 11 +++++------ examples/widgets/dialogs/classwizard/classwizard.py | 2 +- examples/widgets/dialogs/classwizard/listchooser.py | 2 +- .../widgets/dialogs/trivialwizard/trivialwizard.py | 2 +- .../graphicsview/collidingmice/collidingmice.py | 2 +- .../graphicsview/dragdroprobot/dragdroprobot.py | 4 ++-- .../widgets/graphicsview/elasticnodes/elasticnodes.py | 4 ++-- examples/widgets/imageviewer/imageviewer.py | 2 +- .../itemviews/basicfiltermodel/basicsortfiltermodel.py | 6 +++--- examples/widgets/itemviews/fetchmore/fetchmore.py | 2 +- .../itemviews/spinboxdelegate/spinboxdelegate.py | 3 ++- .../widgets/itemviews/stardelegate/stardelegate.py | 2 +- examples/widgets/itemviews/stardelegate/starrating.py | 6 +++--- .../widgets/layouts/dynamiclayouts/dynamiclayouts.py | 4 ++-- .../widgets/mainwindows/dockwidgets/dockwidgets.py | 9 +++++---- examples/widgets/mainwindows/mdi/mdi.py | 2 +- examples/widgets/painting/basicdrawing/basicdrawing.py | 5 +++-- .../painting/concentriccircles/concentriccircles.py | 2 +- examples/widgets/richtext/orderform/orderform.py | 6 +++--- .../richtext/syntaxhighlighter/syntaxhighlighter.py | 2 +- .../tools/regularexpression/regularexpressiondialog.py | 12 +++++++----- examples/widgets/tutorials/cannon/t10.py | 4 ++-- examples/widgets/tutorials/cannon/t12.py | 4 ++-- examples/widgets/tutorials/cannon/t13.py | 4 ++-- examples/widgets/tutorials/cannon/t14.py | 4 ++-- examples/widgets/tutorials/cannon/t8.py | 4 ++-- examples/widgets/tutorials/cannon/t9.py | 4 ++-- .../widgets/tutorials/modelview/3_changingmodel.py | 1 + examples/widgets/tutorials/modelview/6_treeview.py | 1 + examples/widgets/tutorials/modelview/7_selections.py | 1 + examples/widgets/widgets/tetrix/tetrix.py | 4 ++-- 70 files changed, 135 insertions(+), 112 deletions(-) (limited to 'examples') diff --git a/examples/axcontainer/axviewer/axviewer.py b/examples/axcontainer/axviewer/axviewer.py index abc0599e5..c22207f36 100644 --- a/examples/axcontainer/axviewer/axviewer.py +++ b/examples/axcontainer/axviewer/axviewer.py @@ -7,7 +7,7 @@ import sys from PySide6.QtAxContainer import QAxSelect, QAxWidget from PySide6.QtGui import QAction from PySide6.QtWidgets import (QApplication, QDialog, - QMainWindow, QMessageBox, QToolBar) + QMainWindow, QMessageBox, QToolBar) class MainWindow(QMainWindow): diff --git a/examples/bluetooth/heartrate_game/heartrate_global.py b/examples/bluetooth/heartrate_game/heartrate_global.py index dec6f83a3..88c34b876 100644 --- a/examples/bluetooth/heartrate_game/heartrate_global.py +++ b/examples/bluetooth/heartrate_game/heartrate_global.py @@ -16,4 +16,5 @@ def set_simulator(s): global _simulator _simulator = s + is_android = os.environ.get('ANDROID_ARGUMENT') diff --git a/examples/bluetooth/heartrate_server/heartrate_server.py b/examples/bluetooth/heartrate_server/heartrate_server.py index f98cc6fe8..801584565 100644 --- a/examples/bluetooth/heartrate_server/heartrate_server.py +++ b/examples/bluetooth/heartrate_server/heartrate_server.py @@ -67,7 +67,7 @@ if __name__ == '__main__': value.append(chr(0)) # Flags that specify the format of the value. value.append(chr(current_heart_rate)) # Actual value. characteristic = service.characteristic(QBluetoothUuid.CharacteristicType.HeartRateMeasurement) - assert(characteristic.isValid()) + assert characteristic.isValid() # Potentially causes notification. service.writeCharacteristic(characteristic, value) if current_heart_rate == 60: diff --git a/examples/bluetooth/lowenergyscanner/device.py b/examples/bluetooth/lowenergyscanner/device.py index e69a8450e..95d1fe158 100644 --- a/examples/bluetooth/lowenergyscanner/device.py +++ b/examples/bluetooth/lowenergyscanner/device.py @@ -13,6 +13,7 @@ from characteristicinfo import CharacteristicInfo QML_IMPORT_NAME = "Scanner" QML_IMPORT_MAJOR_VERSION = 1 + @QmlElement @QmlSingleton class Device(QObject): diff --git a/examples/charts/chartthemes/main.py b/examples/charts/chartthemes/main.py index 28c819c16..3a058804d 100644 --- a/examples/charts/chartthemes/main.py +++ b/examples/charts/chartthemes/main.py @@ -7,7 +7,7 @@ import sys from PySide6.QtCore import QPointF, Qt from PySide6.QtGui import QColor, QPainter, QPalette from PySide6.QtWidgets import (QApplication, QMainWindow, QSizePolicy, - QWidget) + QWidget) from PySide6.QtCharts import (QAreaSeries, QBarSet, QChart, QChartView, QLineSeries, QPieSeries, QScatterSeries, QSplineSeries, QStackedBarSeries) @@ -273,7 +273,6 @@ class ThemeWidget(QWidget): for chart_view in self.charts: chart_view.chart().setTheme(theme) - # Set palette colors based on selected theme if theme == QChart.ChartThemeLight: set_colors(QColor(0xf0f0f0), QColor(0x404044)) diff --git a/examples/charts/donutbreakdown/donutbreakdown.py b/examples/charts/donutbreakdown/donutbreakdown.py index 1597685c2..9111d4aac 100644 --- a/examples/charts/donutbreakdown/donutbreakdown.py +++ b/examples/charts/donutbreakdown/donutbreakdown.py @@ -38,7 +38,7 @@ class MainSlice(QPieSlice): class DonutBreakdownChart(QChart): def __init__(self, parent=None): super().__init__(QChart.ChartTypeCartesian, - parent, Qt.WindowFlags()) + parent, Qt.WindowFlags()) self.main_series = QPieSeries() self.main_series.setPieSize(0.7) self.addSeries(self.main_series) diff --git a/examples/charts/legend/legend.py b/examples/charts/legend/legend.py index f1929547d..39b9543f4 100644 --- a/examples/charts/legend/legend.py +++ b/examples/charts/legend/legend.py @@ -7,7 +7,8 @@ import sys from PySide6.QtCore import Qt, QRectF, Slot from PySide6.QtGui import QBrush, QColor, QPainter, QPen from PySide6.QtWidgets import (QApplication, QDoubleSpinBox, - QFormLayout, QGridLayout, QGroupBox, QPushButton, QWidget) + QFormLayout, QGridLayout, QGroupBox, + QPushButton, QWidget) from PySide6.QtCharts import QBarSeries, QBarSet, QChart, QChartView diff --git a/examples/charts/memoryusage/memoryusage.py b/examples/charts/memoryusage/memoryusage.py index d0bf842e5..3ba42368e 100644 --- a/examples/charts/memoryusage/memoryusage.py +++ b/examples/charts/memoryusage/memoryusage.py @@ -54,7 +54,7 @@ def get_memory_usage(): legend = f'{command} {memory_usage}%' result.append([legend, memory_usage]) - result.sort(key = lambda x: x[1], reverse=True) + result.sort(key=lambda x: x[1], reverse=True) return result diff --git a/examples/charts/modeldata/modeldata.py b/examples/charts/modeldata/modeldata.py index 646021037..d18feafa7 100644 --- a/examples/charts/modeldata/modeldata.py +++ b/examples/charts/modeldata/modeldata.py @@ -9,7 +9,7 @@ from random import randrange from PySide6.QtCore import QAbstractTableModel, QModelIndex, QRect, Qt from PySide6.QtGui import QColor, QPainter from PySide6.QtWidgets import (QApplication, QGridLayout, QHeaderView, - QTableView, QWidget) + QTableView, QWidget) from PySide6.QtCharts import QChart, QChartView, QLineSeries, QVXYModelMapper diff --git a/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py b/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py index 4f9540d42..20a65bdaf 100644 --- a/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py +++ b/examples/charts/pointselectionandmarkers/pointselectionandmarkers.py @@ -20,12 +20,12 @@ if __name__ == "__main__": marker_size = 20. series = QSplineSeries() series.append([QPointF(0, 0), - QPointF(0.5, 2.27), - QPointF(1.5, 2.2), - QPointF(3.3, 1.7), - QPointF(4.23, 3.1), - QPointF(5.3, 2.3), - QPointF(6.47, 4.1)]) + QPointF(0.5, 2.27), + QPointF(1.5, 2.2), + QPointF(3.3, 1.7), + QPointF(4.23, 3.1), + QPointF(5.3, 2.3), + QPointF(6.47, 4.1)]) series.setMarkerSize(marker_size) series.setLightMarker(Utilities.default_light_marker(marker_size)) series.setSelectedLightMarker(Utilities.default_selected_light_marker(marker_size)) @@ -66,7 +66,6 @@ if __name__ == "__main__": char_point_combobox.addItems(["Red rectangle", "Green triangle", "Orange circle"]) char_point_combobox.currentIndexChanged.connect(set_light_marker) - @Slot(int) def set_selected_light_marker(index): series.setSelectedLightMarker(Utilities.get_selected_point_representation(Utilities.selected_point_type(index), marker_size)) @@ -75,7 +74,6 @@ if __name__ == "__main__": char_point_selected_combobox.addItems(["Blue triangle", "Yellow rectangle", "Lavender circle"]) char_point_selected_combobox.currentIndexChanged.connect(set_selected_light_marker) - @Slot(int) def set_line_color(index): series.setColor(Utilities.make_line_color(Utilities.line_color(index))) @@ -84,7 +82,6 @@ if __name__ == "__main__": line_color_combobox.addItems(["Blue", "Black", "Mint"]) line_color_combobox.currentIndexChanged.connect(set_line_color) - @Slot(int) def display_unselected_points(checkbox_state): if checkbox_state: @@ -96,7 +93,6 @@ if __name__ == "__main__": show_unselected_points_checkbox.setChecked(True) show_unselected_points_checkbox.stateChanged.connect(display_unselected_points) - control_label = QLabel("Marker and Selection Controls") control_label.setAlignment(Qt.AlignHCenter) control_label_font = control_label.font() diff --git a/examples/charts/pointselectionandmarkers/utilities.py b/examples/charts/pointselectionandmarkers/utilities.py index 6b96d6e26..ee36e855a 100644 --- a/examples/charts/pointselectionandmarkers/utilities.py +++ b/examples/charts/pointselectionandmarkers/utilities.py @@ -6,6 +6,7 @@ from PySide6.QtCore import Qt import rc_markers + def rectangle(point_type, image_size): image = QImage(image_size, image_size, QImage.Format_RGB32) painter = QPainter() @@ -15,9 +16,11 @@ def rectangle(point_type, image_size): painter.end() return image + def triangle(point_type, image_size): return QImage(point_type[3]).scaled(image_size, image_size) + def circle(point_type, image_size): image = QImage(image_size, image_size, QImage.Format_ARGB32) image.fill(QColor(0, 0, 0, 0)) @@ -32,6 +35,7 @@ def circle(point_type, image_size): painter.end() return image + _point_types = [("RedRectangle", rectangle, Qt.red), ("GreenTriangle", triangle, Qt.green, ":/images/green_triangle.png"), ("OrangeCircle", circle, QColor(255, 127, 80))] @@ -40,12 +44,15 @@ _selected_point_types = [("BlueTriangle", triangle, Qt.blue, ":/images/blue_tria ("LavenderCircle", circle, QColor(147, 112, 219))] _line_colors = [("Blue", QColor(65, 105, 225)), ("Black", Qt.black), ("Mint", QColor(70, 203, 155))] + def point_type(index): return _point_types[index] + def selected_point_type(index): return _selected_point_types[index] + def line_color(index): return _line_colors[index] @@ -53,6 +60,7 @@ def line_color(index): def default_light_marker(image_size): return rectangle(_point_types[0], image_size) + def default_selected_light_marker(image_size): return triangle(_selected_point_types[0], image_size) @@ -60,8 +68,10 @@ def default_selected_light_marker(image_size): def get_point_representation(point_type, image_size): return point_type[1](point_type, image_size) + def get_selected_point_representation(point_type, image_size): return point_type[1](point_type, image_size) + def make_line_color(line_color): return line_color[1] diff --git a/examples/corelib/settingseditor/settingseditor.py b/examples/corelib/settingseditor/settingseditor.py index a77349e5e..ca4369149 100644 --- a/examples/corelib/settingseditor/settingseditor.py +++ b/examples/corelib/settingseditor/settingseditor.py @@ -7,14 +7,20 @@ import sys from PySide6.QtCore import (QByteArray, QDate, QDateTime, QDir, QEvent, QPoint, - QRect, QRegularExpression, QSettings, QSize, QTime, QTimer, Qt, Slot) + QRect, QRegularExpression, QSettings, QSize, QTime, + QTimer, Qt, Slot) from PySide6.QtGui import (QAction, QColor, QIcon, QIntValidator, - QDoubleValidator, QRegularExpressionValidator, QValidator) + QDoubleValidator, QRegularExpressionValidator, + QValidator) from PySide6.QtWidgets import (QAbstractItemView, QApplication, - QCheckBox, QComboBox, QFileDialog, QDialog, QDialogButtonBox, QGridLayout, - QGroupBox, QHeaderView, QInputDialog, QItemDelegate, QLabel, QLineEdit, - QMainWindow, QMessageBox, QStyle, QSpinBox, QStyleOptionViewItem, - QTableWidget, QTableWidgetItem, QTreeWidget, QTreeWidgetItem, QVBoxLayout) + QCheckBox, QComboBox, QFileDialog, QDialog, + QDialogButtonBox, QGridLayout, + QGroupBox, QHeaderView, QInputDialog, + QItemDelegate, QLabel, QLineEdit, + QMainWindow, QMessageBox, QStyle, QSpinBox, + QStyleOptionViewItem, QTableWidget, + QTableWidgetItem, QTreeWidget, QTreeWidgetItem, + QVBoxLayout) class TypeChecker: diff --git a/examples/corelib/threads/mandelbrot.py b/examples/corelib/threads/mandelbrot.py index b8cab06ef..f9cc4559b 100644 --- a/examples/corelib/threads/mandelbrot.py +++ b/examples/corelib/threads/mandelbrot.py @@ -30,7 +30,7 @@ INFO_KEY = 'info' HELP = ("Use mouse wheel or the '+' and '-' keys to zoom. Press and " - "hold left mouse button to scroll.") + "hold left mouse button to scroll.") class RenderThread(QThread): @@ -302,7 +302,7 @@ class MandelbrotWidget(QWidget): delta_y = (self.height() - self.pixmap.height()) / 2 - self._pixmap_offset.y() self.scroll(delta_x, delta_y) - @Slot(QImage,float) + @Slot(QImage, float) def update_pixmap(self, image, scale_factor): if not self._last_drag_pos.isNull(): return diff --git a/examples/dbus/pingpong/ping.py b/examples/dbus/pingpong/ping.py index 8dd741c0e..0fbb23ca8 100644 --- a/examples/dbus/pingpong/ping.py +++ b/examples/dbus/pingpong/ping.py @@ -5,7 +5,7 @@ import sys from PySide6.QtCore import QCoreApplication -from PySide6.QtDBus import QDBusConnection, QDBusInterface, QDBusReply +from PySide6.QtDBus import QDBusConnection, QDBusInterface, QDBusReply SERVICE_NAME = 'org.example.QtDBus.PingExample' diff --git a/examples/designer/taskmenuextension/tictactoeplugin.py b/examples/designer/taskmenuextension/tictactoeplugin.py index 0d538443f..f9c925133 100644 --- a/examples/designer/taskmenuextension/tictactoeplugin.py +++ b/examples/designer/taskmenuextension/tictactoeplugin.py @@ -5,7 +5,7 @@ from tictactoe import TicTacToe from tictactoetaskmenu import TicTacToeTaskMenuFactory from PySide6.QtGui import QIcon -from PySide6.QtDesigner import QDesignerCustomWidgetInterface +from PySide6.QtDesigner import QDesignerCustomWidgetInterface DOM_XML = """ diff --git a/examples/installer_test/hello.py b/examples/installer_test/hello.py index a9819477b..3921b5d51 100644 --- a/examples/installer_test/hello.py +++ b/examples/installer_test/hello.py @@ -31,7 +31,7 @@ class MyWidget(QWidget): super().__init__() self.hello = ["Hallo Welt", "你好,世界", "Hei maailma", - "Hola Mundo", "Привет мир"] + "Hola Mundo", "Привет мир"] self.button = QPushButton("Click me!") self.text = QLabel(f"Hello World auto_quit={auto_quit}") diff --git a/examples/multimedia/audiooutput/audiooutput.py b/examples/multimedia/audiooutput/audiooutput.py index e0634e751..e1b4032c6 100644 --- a/examples/multimedia/audiooutput/audiooutput.py +++ b/examples/multimedia/audiooutput/audiooutput.py @@ -54,7 +54,7 @@ class Generator(QIODevice): scaler = lambda x: x * 32767 pack_format = 'h' - assert(pack_format != '') + assert pack_format != '' channel_bytes = fmt.bytesPerSample() sample_bytes = fmt.channelCount() * channel_bytes diff --git a/examples/multimedia/audiosource/audiosource.py b/examples/multimedia/audiosource/audiosource.py index 555e0b937..c2e97c15f 100644 --- a/examples/multimedia/audiosource/audiosource.py +++ b/examples/multimedia/audiosource/audiosource.py @@ -41,6 +41,7 @@ is_android = os.environ.get('ANDROID_ARGUMENT') if is_android: from PySide6.QtCore import QCoreApplication, QMicrophonePermission + class AudioInfo: def __init__(self, format: QAudioFormat): super().__init__() diff --git a/examples/multimedia/camera/videosettings.py b/examples/multimedia/camera/videosettings.py index 2359bd55b..a88cb39ed 100644 --- a/examples/multimedia/camera/videosettings.py +++ b/examples/multimedia/camera/videosettings.py @@ -14,7 +14,6 @@ else: from ui_videosettings import Ui_VideoSettingsUi - def box_value(box): idx = box.currentIndex() return None if idx == -1 else box.itemData(idx) diff --git a/examples/multimedia/player/player.py b/examples/multimedia/player/player.py index 88be50cc3..3124e4fff 100644 --- a/examples/multimedia/player/player.py +++ b/examples/multimedia/player/player.py @@ -7,7 +7,7 @@ import sys from PySide6.QtCore import QStandardPaths, Qt, Slot from PySide6.QtGui import QAction, QIcon, QKeySequence from PySide6.QtWidgets import (QApplication, QDialog, QFileDialog, - QMainWindow, QSlider, QStyle, QToolBar) + QMainWindow, QSlider, QStyle, QToolBar) from PySide6.QtMultimedia import (QAudioOutput, QMediaFormat, QMediaPlayer) from PySide6.QtMultimediaWidgets import QVideoWidget diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.py b/examples/network/blockingfortuneclient/blockingfortuneclient.py index f467cf8d4..816ef67f5 100644 --- a/examples/network/blockingfortuneclient/blockingfortuneclient.py +++ b/examples/network/blockingfortuneclient/blockingfortuneclient.py @@ -5,12 +5,13 @@ """PySide6 port of the network/blockingfortunclient example from Qt v5.x, originating from PyQt""" from PySide6.QtCore import (Signal, QDataStream, QMutex, QMutexLocker, - QThread, QWaitCondition) + QThread, QWaitCondition) from PySide6.QtGui import QIntValidator from PySide6.QtWidgets import (QApplication, QDialogButtonBox, QGridLayout, - QLabel, QLineEdit, QMessageBox, QPushButton, QWidget) + QLabel, QLineEdit, QMessageBox, QPushButton, + QWidget) from PySide6.QtNetwork import (QAbstractSocket, QHostAddress, QNetworkInterface, - QTcpSocket) + QTcpSocket) class FortuneThread(QThread): diff --git a/examples/network/threadedfortuneserver/threadedfortuneserver.py b/examples/network/threadedfortuneserver/threadedfortuneserver.py index 60900708e..bb86d9081 100644 --- a/examples/network/threadedfortuneserver/threadedfortuneserver.py +++ b/examples/network/threadedfortuneserver/threadedfortuneserver.py @@ -7,11 +7,11 @@ import random from PySide6.QtCore import (Signal, QByteArray, QDataStream, QIODevice, - QThread, Qt) + QThread, Qt) from PySide6.QtWidgets import (QApplication, QDialog, QHBoxLayout, QLabel, - QMessageBox, QPushButton, QVBoxLayout) + QMessageBox, QPushButton, QVBoxLayout) from PySide6.QtNetwork import (QHostAddress, QNetworkInterface, QTcpServer, - QTcpSocket) + QTcpSocket) class FortuneThread(QThread): diff --git a/examples/networkauth/redditclient/redditmodel.py b/examples/networkauth/redditclient/redditmodel.py index de81ceb19..fd6f9bc97 100644 --- a/examples/networkauth/redditclient/redditmodel.py +++ b/examples/networkauth/redditclient/redditmodel.py @@ -51,7 +51,7 @@ class RedditModel(QAbstractTableModel): document = QJsonDocument.fromJson(json) root_object = document.object() kind = root_object["kind"] - assert(kind == "Listing") + assert kind == "Listing" data_object = root_object["data"] children_array = data_object["children"] if not children_array: diff --git a/examples/networkauth/redditclient/redditwrapper.py b/examples/networkauth/redditclient/redditwrapper.py index f889a9366..ed4c3d2c7 100644 --- a/examples/networkauth/redditclient/redditwrapper.py +++ b/examples/networkauth/redditclient/redditwrapper.py @@ -19,6 +19,7 @@ NEW_URL = "https://oauth.reddit.com/new" HOT_URL = "https://oauth.reddit.com/hot" LIVE_THREADS_URL = "https://oauth.reddit.com/live/XXXX/about.json" + class RedditWrapper(QObject): authenticated = Signal() @@ -78,7 +79,7 @@ class RedditWrapper(QObject): json = reply.readAll() document = QJsonDocument.fromJson(json) - assert(document.isObject()) + assert document.isObject() root_object = document.object() data_object = root_object["data"] websocketUrl = QUrl(data_object["websocket_url"]) diff --git a/examples/opengl/contextinfo/contextinfo.py b/examples/opengl/contextinfo/contextinfo.py index 37c5f5d43..8507fd9e7 100644 --- a/examples/opengl/contextinfo/contextinfo.py +++ b/examples/opengl/contextinfo/contextinfo.py @@ -15,7 +15,7 @@ from PySide6.QtGui import (QMatrix4x4, QOpenGLContext, QSurfaceFormat, QWindow) from PySide6.QtOpenGL import (QOpenGLBuffer, QOpenGLShader, QOpenGLShaderProgram, QOpenGLVertexArrayObject) from PySide6.QtWidgets import (QApplication, QHBoxLayout, QMessageBox, QPlainTextEdit, - QWidget) + QWidget) from PySide6.support import VoidPtr try: from OpenGL import GL diff --git a/examples/opengl/threadedqopenglwidget/renderer.py b/examples/opengl/threadedqopenglwidget/renderer.py index fbed79423..81ec63cbb 100644 --- a/examples/opengl/threadedqopenglwidget/renderer.py +++ b/examples/opengl/threadedqopenglwidget/renderer.py @@ -120,7 +120,7 @@ class Renderer(QObject, QOpenGLFunctions): if self._exiting: return - assert(ctx.thread() == QThread.currentThread()) + assert ctx.thread() == QThread.currentThread() # Make the context (and an offscreen surface) current for self thread. # The QOpenGLWidget's fbo is bound in the context. diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.py b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.py index 6a7e80ccb..3ab8bcc08 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.py +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.py @@ -12,6 +12,7 @@ from pieslice import PieSlice QML_IMPORT_NAME = "Charts" QML_IMPORT_MAJOR_VERSION = 1 + @QmlElement class PieChart(QQuickItem): def __init__(self, parent=None): diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.py b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.py index 67242a967..6f82f1f10 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.py +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.py @@ -11,6 +11,7 @@ from PySide6.QtQml import QmlElement QML_IMPORT_NAME = "Charts" QML_IMPORT_MAJOR_VERSION = 1 + @QmlElement class PieSlice(QQuickPaintedItem): def __init__(self, parent=None): diff --git a/examples/quick/models/objectlistmodel/objectlistmodel.py b/examples/quick/models/objectlistmodel/objectlistmodel.py index 0843ae480..41110c1af 100644 --- a/examples/quick/models/objectlistmodel/objectlistmodel.py +++ b/examples/quick/models/objectlistmodel/objectlistmodel.py @@ -9,6 +9,7 @@ from PySide6.QtQuick import QQuickView # This example illustrates exposing a list of QObjects as a model in QML + class DataObject(QObject): nameChanged = Signal() @@ -35,7 +36,6 @@ class DataObject(QObject): self._color = color colorChanged.emit() - name = Property(str, name, setName, notify=nameChanged) color = Property(str, color, setColor, notify=colorChanged) diff --git a/examples/quick/models/stringlistmodel/stringlistmodel.py b/examples/quick/models/stringlistmodel/stringlistmodel.py index a7a1807bb..3982b1ffc 100644 --- a/examples/quick/models/stringlistmodel/stringlistmodel.py +++ b/examples/quick/models/stringlistmodel/stringlistmodel.py @@ -15,7 +15,7 @@ if __name__ == '__main__': dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] view = QQuickView() - view.setInitialProperties({"model": dataList }) + view.setInitialProperties({"model": dataList}) qml_file = Path(__file__).parent / "view.qml" view.setSource(QUrl.fromLocalFile(qml_file)) diff --git a/examples/serialbus/modbus/modbusclient/mainwindow.py b/examples/serialbus/modbus/modbusclient/mainwindow.py index 80a336c59..99a360236 100644 --- a/examples/serialbus/modbus/modbusclient/mainwindow.py +++ b/examples/serialbus/modbus/modbusclient/mainwindow.py @@ -316,7 +316,7 @@ class MainWindow(QMainWindow): # do not go beyond 10 entries number_of_entries = min(int(self.ui.readSize.currentText()), - 10 - start_address) + 10 - start_address) return QModbusDataUnit(table, start_address, number_of_entries) def write_request(self): diff --git a/examples/serialport/terminal/settingsdialog.py b/examples/serialport/terminal/settingsdialog.py index 07034e4a6..57b5a6bae 100644 --- a/examples/serialport/terminal/settingsdialog.py +++ b/examples/serialport/terminal/settingsdialog.py @@ -29,7 +29,7 @@ class Settings(): self.string_data_bits = "" self.parity = QSerialPort.NoParity self.string_parity = "" - self.stop_bits = QSerialPort.OneStop + self.stop_bits = QSerialPort.OneStop self.string_stop_bits = "" self.flow_control = QSerialPort.SoftwareControl self.string_flow_control = "" diff --git a/examples/spatialaudio/audiopanning/main.py b/examples/spatialaudio/audiopanning/main.py index 55770e3b6..19b6c3bbd 100644 --- a/examples/spatialaudio/audiopanning/main.py +++ b/examples/spatialaudio/audiopanning/main.py @@ -149,7 +149,7 @@ class AudioWidget(QWidget): self._file_dialog = QFileDialog(self, "Open Audio File", directory) self._file_dialog.setAcceptMode(QFileDialog.AcceptOpen) mime_types = ["audio/mpeg", "audio/aac", "audio/x-ms-wma", - "audio/x-flac+ogg", "audio/x-wav"] + "audio/x-flac+ogg", "audio/x-wav"] self._file_dialog.setMimeTypeFilters(mime_types) self._file_dialog.selectMimeTypeFilter(mime_types[0]) diff --git a/examples/sql/books/bookdelegate.py b/examples/sql/books/bookdelegate.py index 1d1dba86e..7015d5158 100644 --- a/examples/sql/books/bookdelegate.py +++ b/examples/sql/books/bookdelegate.py @@ -53,7 +53,6 @@ class BookDelegate(QSqlRelationalDelegate): painter.drawPixmap(x, y, self.star) x += width - pen = painter.pen() painter.setPen(option.palette.color(QPalette.Mid)) painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight()) diff --git a/examples/utils/pyside_config.py b/examples/utils/pyside_config.py index feb56ed1c..b9f962b8d 100644 --- a/examples/utils/pyside_config.py +++ b/examples/utils/pyside_config.py @@ -212,7 +212,7 @@ def python_link_flags_qmake(): # e.g.: "Program Files" to "Progra~1" for d in libdir.split("\\"): if " " in d: - libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") + libdir = libdir.replace(d, d.split(" ")[0][:-1] + "~1") lib_flags = flags['lib'] return f'-L{libdir} -l{lib_flags}' elif sys.platform == 'darwin': diff --git a/examples/webenginequick/nanobrowser/quicknanobrowser.py b/examples/webenginequick/nanobrowser/quicknanobrowser.py index ae4543ac2..18b67b762 100644 --- a/examples/webenginequick/nanobrowser/quicknanobrowser.py +++ b/examples/webenginequick/nanobrowser/quicknanobrowser.py @@ -40,8 +40,8 @@ class Utils(QObject): if __name__ == '__main__': - QCoreApplication.setApplicationName("Quick Nano Browser"); - QCoreApplication.setOrganizationName("QtProject"); + QCoreApplication.setApplicationName("Quick Nano Browser") + QCoreApplication.setOrganizationName("QtProject") QtWebEngineQuick.initialize() diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.py b/examples/webenginewidgets/simplebrowser/downloadwidget.py index 89dc2889a..6f3dbf78f 100644 --- a/examples/webenginewidgets/simplebrowser/downloadwidget.py +++ b/examples/webenginewidgets/simplebrowser/downloadwidget.py @@ -25,7 +25,6 @@ def with_unit(bytes): class DownloadWidget(QFrame): """Displays one ongoing or finished download (QWebEngineDownloadRequest).""" - # This signal is emitted when the user indicates that they want to remove # this download from the downloads list. remove_clicked = Signal(QWidget) diff --git a/examples/webenginewidgets/widgetsnanobrowser/widgetsnanobrowser.py b/examples/webenginewidgets/widgetsnanobrowser/widgetsnanobrowser.py index 48f60c6a8..2db865996 100644 --- a/examples/webenginewidgets/widgetsnanobrowser/widgetsnanobrowser.py +++ b/examples/webenginewidgets/widgetsnanobrowser/widgetsnanobrowser.py @@ -7,7 +7,7 @@ import sys from PySide6.QtCore import QUrl, Slot from PySide6.QtGui import QIcon from PySide6.QtWidgets import (QApplication, QLineEdit, - QMainWindow, QPushButton, QToolBar) + QMainWindow, QPushButton, QToolBar) from PySide6.QtWebEngineCore import QWebEnginePage from PySide6.QtWebEngineWidgets import QWebEngineView diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py index b621ec117..fe524361d 100644 --- a/examples/widgets/animation/animatedtiles/animatedtiles.py +++ b/examples/widgets/animation/animatedtiles/animatedtiles.py @@ -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() @@ -172,7 +172,7 @@ if __name__ == '__main__': # Random. random_state.assignProperty(item, 'pos', QPointF(-250 + generator.bounded(0, 500), - -250 + generator.bounded(0, 500))) + -250 + generator.bounded(0, 500))) # Tiled. tiled_state.assignProperty(item, 'pos', diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py index f8cba0060..c8a87e8c5 100644 --- a/examples/widgets/animation/easing/easing.py +++ b/examples/widgets/animation/easing/easing.py @@ -125,7 +125,6 @@ class Window(QWidget): curve_types = [(f"QEasingCurve.{e.name}", e) for e in QEasingCurve.Type if e.value <= 40] - with QPainter(pix) as painter: for curve_name, curve_type in curve_types: @@ -151,7 +150,7 @@ class Window(QWidget): # 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() @@ -159,7 +158,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 @@ -185,14 +184,14 @@ class Window(QWidget): self._anim.setCurrentTime(0) is_elastic = (curve_type.value >= QEasingCurve.InElastic.value - and curve_type.value <= QEasingCurve.OutInElastic.value) + and curve_type.value <= QEasingCurve.OutInElastic.value) is_bounce = (curve_type.value >= QEasingCurve.InBounce.value - and curve_type.value <= QEasingCurve.OutInBounce.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.value >= QEasingCurve.InBack.value - and curve_type.value <= QEasingCurve.OutInBack.value) + and curve_type.value <= QEasingCurve.OutInBack.value) def path_changed(self, index): self._anim.set_path_type(index) diff --git a/examples/widgets/dialogs/classwizard/classwizard.py b/examples/widgets/dialogs/classwizard/classwizard.py index 296cff06e..e7893b3b7 100644 --- a/examples/widgets/dialogs/classwizard/classwizard.py +++ b/examples/widgets/dialogs/classwizard/classwizard.py @@ -333,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/listchooser.py b/examples/widgets/dialogs/classwizard/listchooser.py index bf15be88c..6bf47c6d1 100644 --- a/examples/widgets/dialogs/classwizard/listchooser.py +++ b/examples/widgets/dialogs/classwizard/listchooser.py @@ -27,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/trivialwizard/trivialwizard.py b/examples/widgets/dialogs/trivialwizard/trivialwizard.py index 0eb9fb567..2e551ae19 100644 --- a/examples/widgets/dialogs/trivialwizard/trivialwizard.py +++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.py @@ -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/graphicsview/collidingmice/collidingmice.py b/examples/widgets/graphicsview/collidingmice/collidingmice.py index 53c5c1aab..7cce60b22 100644 --- a/examples/widgets/graphicsview/collidingmice/collidingmice.py +++ b/examples/widgets/graphicsview/collidingmice/collidingmice.py @@ -26,7 +26,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__() diff --git a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py index 0bfd3e0db..5469fc731 100644 --- a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py +++ b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py @@ -154,7 +154,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 +169,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) diff --git a/examples/widgets/graphicsview/elasticnodes/elasticnodes.py b/examples/widgets/graphicsview/elasticnodes/elasticnodes.py index 58d9d4a90..d77a35796 100644 --- a/examples/widgets/graphicsview/elasticnodes/elasticnodes.py +++ b/examples/widgets/graphicsview/elasticnodes/elasticnodes.py @@ -192,7 +192,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() @@ -362,7 +362,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") diff --git a/examples/widgets/imageviewer/imageviewer.py b/examples/widgets/imageviewer/imageviewer.py index ded7f246a..93b1e87ba 100644 --- a/examples/widgets/imageviewer/imageviewer.py +++ b/examples/widgets/imageviewer/imageviewer.py @@ -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/basicfiltermodel/basicsortfiltermodel.py b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py index 834237404..0071d60f3 100644 --- a/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py +++ b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py @@ -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) diff --git a/examples/widgets/itemviews/fetchmore/fetchmore.py b/examples/widgets/itemviews/fetchmore/fetchmore.py index ecee86e38..711642588 100644 --- a/examples/widgets/itemviews/fetchmore/fetchmore.py +++ b/examples/widgets/itemviews/fetchmore/fetchmore.py @@ -112,7 +112,7 @@ class Window(QWidget): self.setWindowTitle("Fetch More Example") - @Slot(str,int,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/spinboxdelegate/spinboxdelegate.py b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py index 266b8c1e1..577f0faa5 100644 --- a/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py +++ b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.py @@ -10,6 +10,7 @@ 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 @@ -52,7 +53,7 @@ class SpinBoxDelegate(QStyledItemDelegate): if __name__ == '__main__': app = QApplication(sys.argv) - model= QStandardItemModel(4, 2) + model = QStandardItemModel(4, 2) tableView = QTableView() tableView.setModel(model) diff --git a/examples/widgets/itemviews/stardelegate/stardelegate.py b/examples/widgets/itemviews/stardelegate/stardelegate.py index 87bf1ff48..ceb7a83b4 100644 --- a/examples/widgets/itemviews/stardelegate/stardelegate.py +++ b/examples/widgets/itemviews/stardelegate/stardelegate.py @@ -112,7 +112,7 @@ if __name__ == "__main__": table_widget = QTableWidget(4, 4) table_widget.setItemDelegate(StarDelegate()) table_widget.setEditTriggers(QAbstractItemView.DoubleClicked | - QAbstractItemView.SelectedClicked) + QAbstractItemView.SelectedClicked) table_widget.setSelectionBehavior(QAbstractItemView.SelectRows) table_widget.setHorizontalHeaderLabels(["Title", "Genre", "Artist", "Rating"]) 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/dynamiclayouts/dynamiclayouts.py b/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py index 4e3791519..09f01c8cc 100644 --- a/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py +++ b/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.py @@ -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") diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py index 6d0e95a81..9b57b264b 100644 --- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py +++ b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py @@ -8,10 +8,11 @@ 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 @@ -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() diff --git a/examples/widgets/mainwindows/mdi/mdi.py b/examples/widgets/mainwindows/mdi/mdi.py index 927a1daa7..f55cfe17a 100644 --- a/examples/widgets/mainwindows/mdi/mdi.py +++ b/examples/widgets/mainwindows/mdi/mdi.py @@ -435,7 +435,7 @@ if __name__ == '__main__': icon_paths = QIcon.themeSearchPaths() QIcon.setThemeSearchPaths(icon_paths + [":/qt-project.org/icons"]) - QIcon.setFallbackThemeName("example_icons"); + QIcon.setFallbackThemeName("example_icons") main_win = MainWindow() for f in options.files: diff --git a/examples/widgets/painting/basicdrawing/basicdrawing.py b/examples/widgets/painting/basicdrawing/basicdrawing.py index c1f2a5b0c..2af70a543 100644 --- a/examples/widgets/painting/basicdrawing/basicdrawing.py +++ b/examples/widgets/painting/basicdrawing/basicdrawing.py @@ -6,9 +6,10 @@ 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 diff --git a/examples/widgets/painting/concentriccircles/concentriccircles.py b/examples/widgets/painting/concentriccircles/concentriccircles.py index 0edc9cb9f..7b2820575 100644 --- a/examples/widgets/painting/concentriccircles/concentriccircles.py +++ b/examples/widgets/painting/concentriccircles/concentriccircles.py @@ -7,7 +7,7 @@ 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): diff --git a/examples/widgets/richtext/orderform/orderform.py b/examples/widgets/richtext/orderform/orderform.py index fd0be01fe..dea856a72 100644 --- a/examples/widgets/richtext/orderform/orderform.py +++ b/examples/widgets/richtext/orderform/orderform.py @@ -153,8 +153,8 @@ 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): @@ -162,7 +162,7 @@ class MainWindow(QMainWindow): 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): diff --git a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py index c329eefd6..8079b4a43 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): diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.py b/examples/widgets/tools/regularexpression/regularexpressiondialog.py index 4fc9c62a2..ab48fa517 100644 --- a/examples/widgets/tools/regularexpression/regularexpressiondialog.py +++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.py @@ -5,12 +5,14 @@ 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) def rawStringLiteral(pattern: str) -> str: @@ -42,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('"'): diff --git a/examples/widgets/tutorials/cannon/t10.py b/examples/widgets/tutorials/cannon/t10.py index c9c3fa7f6..f36c619f6 100644 --- a/examples/widgets/tutorials/cannon/t10.py +++ b/examples/widgets/tutorials/cannon/t10.py @@ -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) diff --git a/examples/widgets/tutorials/cannon/t12.py b/examples/widgets/tutorials/cannon/t12.py index 8847b2208..c4a05cbc3 100644 --- a/examples/widgets/tutorials/cannon/t12.py +++ b/examples/widgets/tutorials/cannon/t12.py @@ -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) diff --git a/examples/widgets/tutorials/cannon/t13.py b/examples/widgets/tutorials/cannon/t13.py index 4eb45a374..a5aa42e67 100644 --- a/examples/widgets/tutorials/cannon/t13.py +++ b/examples/widgets/tutorials/cannon/t13.py @@ -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) diff --git a/examples/widgets/tutorials/cannon/t14.py b/examples/widgets/tutorials/cannon/t14.py index e4f1c350d..5e74443ed 100644 --- a/examples/widgets/tutorials/cannon/t14.py +++ b/examples/widgets/tutorials/cannon/t14.py @@ -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) diff --git a/examples/widgets/tutorials/cannon/t8.py b/examples/widgets/tutorials/cannon/t8.py index b82e24a01..d805e5f8d 100644 --- a/examples/widgets/tutorials/cannon/t8.py +++ b/examples/widgets/tutorials/cannon/t8.py @@ -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) diff --git a/examples/widgets/tutorials/cannon/t9.py b/examples/widgets/tutorials/cannon/t9.py index 297e98e50..67a9d9fd3 100644 --- a/examples/widgets/tutorials/cannon/t9.py +++ b/examples/widgets/tutorials/cannon/t9.py @@ -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) diff --git a/examples/widgets/tutorials/modelview/3_changingmodel.py b/examples/widgets/tutorials/modelview/3_changingmodel.py index e277dd1e8..2148ec5d3 100644 --- a/examples/widgets/tutorials/modelview/3_changingmodel.py +++ b/examples/widgets/tutorials/modelview/3_changingmodel.py @@ -43,6 +43,7 @@ class MyModel(QAbstractTableModel): self.dataChanged.emit(top_left, top_left, [Qt.DisplayRole]) #! [3] + if __name__ == '__main__': app = QApplication(sys.argv) table_view = QTableView() diff --git a/examples/widgets/tutorials/modelview/6_treeview.py b/examples/widgets/tutorials/modelview/6_treeview.py index 09300560c..cac3c6d53 100644 --- a/examples/widgets/tutorials/modelview/6_treeview.py +++ b/examples/widgets/tutorials/modelview/6_treeview.py @@ -8,6 +8,7 @@ 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): diff --git a/examples/widgets/tutorials/modelview/7_selections.py b/examples/widgets/tutorials/modelview/7_selections.py index 6c519c865..c879d8f67 100644 --- a/examples/widgets/tutorials/modelview/7_selections.py +++ b/examples/widgets/tutorials/modelview/7_selections.py @@ -9,6 +9,7 @@ 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): diff --git a/examples/widgets/widgets/tetrix/tetrix.py b/examples/widgets/widgets/tetrix/tetrix.py index 36cbb3448..062629d46 100644 --- a/examples/widgets/widgets/tetrix/tetrix.py +++ b/examples/widgets/widgets/tetrix/tetrix.py @@ -349,7 +349,7 @@ 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, @@ -379,7 +379,7 @@ class TetrixPiece(object): ) 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) -- cgit v1.2.3