diff options
Diffstat (limited to 'examples')
39 files changed, 331 insertions, 177 deletions
diff --git a/examples/3d/simple3d.py b/examples/3d/simple3d.py index 3cfa39a05..b97ee79d1 100644 --- a/examples/3d/simple3d.py +++ b/examples/3d/simple3d.py @@ -82,7 +82,7 @@ class OrbitTransformController(QObject): return self._angle def updateMatrix(self): - self._matrix.setToIdentity(); + self._matrix.setToIdentity() self._matrix.rotate(self._angle, QVector3D(0, 1, 0)) self._matrix.translate(self._radius, 0, 0) if self._target is not None: @@ -146,7 +146,7 @@ class Window(Qt3DExtras.Qt3DWindow): self.sphereRotateTransformAnimation = QPropertyAnimation(self.sphereTransform) self.sphereRotateTransformAnimation.setTargetObject(self.controller) - self.sphereRotateTransformAnimation.setPropertyName("angle") + self.sphereRotateTransformAnimation.setPropertyName(b"angle") self.sphereRotateTransformAnimation.setStartValue(0) self.sphereRotateTransformAnimation.setEndValue(360) self.sphereRotateTransformAnimation.setDuration(10000) diff --git a/examples/charts/callout.py b/examples/charts/callout.py index 2b2a4cbb9..4b18b6497 100644 --- a/examples/charts/callout.py +++ b/examples/charts/callout.py @@ -75,7 +75,7 @@ class Callout(QGraphicsItem): path = QPainterPath() path.addRoundedRect(self._rect, 5, 5) anchor = self.mapFromParent(self._chart.mapToPosition(self._anchor)) - if not self._rect.contains(anchor): + if not self._rect.contains(anchor) and not self._anchor.isNull(): point1 = QPointF() point2 = QPointF() @@ -131,7 +131,7 @@ class Callout(QGraphicsItem): if event.buttons() & Qt.LeftButton: self.setPos(mapToParent( event.pos() - event.buttonDownPos(Qt.LeftButton))) - event.setAccepted(Ttrue) + event.setAccepted(True) else: event.setAccepted(False) diff --git a/examples/charts/memoryusage.py b/examples/charts/memoryusage.py index ac4d3c4e3..b2c8ed153 100644 --- a/examples/charts/memoryusage.py +++ b/examples/charts/memoryusage.py @@ -52,10 +52,8 @@ def runProcess(command, arguments): process = QProcess() process.start(command, arguments) process.waitForFinished() - result = [] - for line in str(process.readAllStandardOutput()).split(os.linesep): - result.append(line) - return result + std_output = process.readAllStandardOutput().data().decode('utf-8') + return std_output.split('\n') def getMemoryUsage(): result = [] @@ -82,9 +80,9 @@ def getMemoryUsage(): psOptions = ['-e', '-v'] memoryColumn = 11 commandColumn = 12 - for line in runProcess('ps', psOptions)[1:]: + for line in runProcess('ps', psOptions): tokens = line.split(None) - if len(tokens) > commandColumn: # Percentage and command + if len(tokens) > commandColumn and "PID" not in tokens: # Percentage and command command = tokens[commandColumn] if not command.startswith('['): command = os.path.basename(command) diff --git a/examples/datavisualization/bars3d.py b/examples/datavisualization/bars3d.py index e8b568f22..e2fa73206 100644 --- a/examples/datavisualization/bars3d.py +++ b/examples/datavisualization/bars3d.py @@ -68,18 +68,18 @@ class MainWindow(QMainWindow): self.columnAxis.setTitle('Columns') self.columnAxis.setTitleVisible(True) self.columnAxis.setLabels(['Column1', 'Column2']) - self.columnAxis.setLabelAutoRotation(30); + self.columnAxis.setLabelAutoRotation(30) self.rowAxis = QtDataVisualization.QCategory3DAxis() self.rowAxis.setTitle('Rows') self.rowAxis.setTitleVisible(True) self.rowAxis.setLabels(['Row1', 'Row2']) - self.rowAxis.setLabelAutoRotation(30); + self.rowAxis.setLabelAutoRotation(30) self.valueAxis = QtDataVisualization.QValue3DAxis() self.valueAxis.setTitle('Values') self.valueAxis.setTitleVisible(True) - self.valueAxis.setRange(0, 5); + self.valueAxis.setRange(0, 5) self.bars.setRowAxis(self.rowAxis) self.bars.setColumnAxis(self.columnAxis) @@ -104,8 +104,8 @@ class MainWindow(QMainWindow): size = geometry.height() * 3 / 4 self.container.setMinimumSize(size, size) - self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding); - self.container.setFocusPolicy(Qt.StrongFocus); + self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + self.container.setFocusPolicy(Qt.StrongFocus) self.setCentralWidget(self.container) if __name__ == '__main__': diff --git a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py index 024efbf16..9bd9f1e78 100644 --- a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py +++ b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py @@ -51,9 +51,10 @@ from utils import text_type from PySide2.QtCore import Property, QUrl from PySide2.QtGui import QGuiApplication, QPen, QPainter, QColor from PySide2.QtQml import qmlRegisterType -from PySide2.QtQuick import QQuickPaintedItem, QQuickView +from PySide2.QtQuick import QQuickPaintedItem, QQuickView, QQuickItem class PieSlice (QQuickPaintedItem): + def __init__(self, parent = None): QQuickPaintedItem.__init__(self, parent) self._color = QColor() @@ -68,14 +69,14 @@ class PieSlice (QQuickPaintedItem): def paint(self, painter): pen = QPen(self._color, 2) - painter.setPen(pen); - painter.setRenderHints(QPainter.Antialiasing, True); - painter.drawPie(self.boundingRect().adjusted(1,1,-1,-1), 90 * 16, 290 * 16); + painter.setPen(pen) + painter.setRenderHints(QPainter.Antialiasing, True) + painter.drawPie(self.boundingRect().adjusted(1,1,-1,-1), 90 * 16, 290 * 16) -class PieChart (QQuickPaintedItem): +class PieChart (QQuickItem): def __init__(self, parent = None): - QQuickPaintedItem.__init__(self, parent) - self._name = u'' + QQuickItem.__init__(self, parent) + self._name = None self._pieSlice = None def getName(self): diff --git a/examples/declarative/extending/chapter5-listproperties/listproperties.py b/examples/declarative/extending/chapter5-listproperties/listproperties.py index c06e11ca0..1aec72755 100644 --- a/examples/declarative/extending/chapter5-listproperties/listproperties.py +++ b/examples/declarative/extending/chapter5-listproperties/listproperties.py @@ -51,7 +51,7 @@ from utils import text_type from PySide2.QtCore import Property, QUrl from PySide2.QtGui import QGuiApplication, QPen, QPainter, QColor from PySide2.QtQml import qmlRegisterType, ListProperty -from PySide2.QtQuick import QQuickPaintedItem, QQuickView +from PySide2.QtQuick import QQuickPaintedItem, QQuickView, QQuickItem class PieSlice (QQuickPaintedItem): def __init__(self, parent = None): @@ -84,13 +84,13 @@ class PieSlice (QQuickPaintedItem): def paint(self, painter): pen = QPen(self._color, 2) - painter.setPen(pen); - painter.setRenderHints(QPainter.Antialiasing, True); - painter.drawPie(self.boundingRect().adjusted(1,1,-1,-1), self._fromAngle * 16, self._angleSpan * 16); + painter.setPen(pen) + painter.setRenderHints(QPainter.Antialiasing, True) + painter.drawPie(self.boundingRect().adjusted(1,1,-1,-1), self._fromAngle * 16, self._angleSpan * 16) -class PieChart (QQuickPaintedItem): +class PieChart (QQuickItem): def __init__(self, parent = None): - QQuickPaintedItem.__init__(self, parent) + QQuickItem.__init__(self, parent) self._name = u'' self._slices = [] @@ -111,8 +111,8 @@ class PieChart (QQuickPaintedItem): if __name__ == '__main__': app = QGuiApplication(sys.argv) - qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart'); - qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice"); + qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart') + qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) diff --git a/examples/declarative/usingmodel.py b/examples/declarative/usingmodel.py index 494647c10..4b4387117 100644 --- a/examples/declarative/usingmodel.py +++ b/examples/declarative/usingmodel.py @@ -44,9 +44,9 @@ from __future__ import print_function import os import sys -from PySide2.QtCore import QAbstractListModel, Qt, QUrl -from PySide2.QtGui import QGuiApplication import PySide2.QtQml +from PySide2.QtCore import QAbstractListModel, Qt, QUrl, QByteArray +from PySide2.QtGui import QGuiApplication from PySide2.QtQuick import QQuickView class PersonModel (QAbstractListModel): @@ -58,8 +58,8 @@ class PersonModel (QAbstractListModel): def roleNames(self): roles = { - PersonModel.MyRole : 'modelData', - Qt.DisplayRole : 'display' + PersonModel.MyRole : QByteArray(b'modelData'), + Qt.DisplayRole : QByteArray(b'display') } return roles diff --git a/examples/macextras/macpasteboardmime.py b/examples/macextras/macpasteboardmime.py index 412714273..2e0995a23 100755 --- a/examples/macextras/macpasteboardmime.py +++ b/examples/macextras/macpasteboardmime.py @@ -116,7 +116,7 @@ class TestWidget(QtWidgets.QWidget): if e.mimeData().hasFormat("application/x-mycompany-VCard"): s = e.mimeData().data( "application/x-mycompany-VCard" ) # s now contains text of vcard - self.label2.setText(str(s)); + self.label2.setText(str(s)) e.acceptProposedAction() if __name__ == '__main__': diff --git a/examples/multimedia/player.py b/examples/multimedia/player.py index 71604f41f..3e7d9f2c5 100644 --- a/examples/multimedia/player.py +++ b/examples/multimedia/player.py @@ -114,9 +114,9 @@ class MainWindow(QMainWindow): self.videoWidget = QVideoWidget() self.setCentralWidget(self.videoWidget) - self.player.setPlaylist(self.playlist); + self.player.setPlaylist(self.playlist) self.player.stateChanged.connect(self.updateButtons) - self.player.setVideoOutput(self.videoWidget); + self.player.setVideoOutput(self.videoWidget) self.updateButtons(self.player.state()) @@ -136,9 +136,9 @@ class MainWindow(QMainWindow): # Go to previous track if we are within the first 5 seconds of playback # Otherwise, seek to the beginning. if self.player.position() <= 5000: - self.playlist.previous(); + self.playlist.previous() else: - player.setPosition(0); + player.setPosition(0) def updateButtons(self, state): mediaCount = self.playlist.mediaCount() diff --git a/examples/multimedia/shutter.svg b/examples/multimedia/shutter.svg new file mode 100644 index 000000000..18493361d --- /dev/null +++ b/examples/multimedia/shutter.svg @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 23.3 19.4" style="enable-background:new 0 0 23.3 19.4;" xml:space="preserve"> +<style type="text/css"> + .st0{fill:none;} +</style> +<g> + <path class="st0" d="M6.2,4.8H2.4c-0.2,0-0.1-0.1-0.1,0.1V17c0,0.2-0.1,0.8,0.1,0.8h3.9V4.8z"/> + <circle class="st0" cx="14" cy="11" r="4.5"/> + <path class="st0" d="M20.9,4.8h-1.8c-0.3,0-0.6-0.4-0.8-0.6l-1.7-2.4h-5.3L9.7,4.2C9.5,4.4,9.2,4.8,8.9,4.8H7.2v13h13.7 + c0.2,0,0.3-0.6,0.3-0.8V4.9C21.2,4.7,21.1,4.8,20.9,4.8z M14,16.4c-3,0-5.5-2.4-5.5-5.5c0-3,2.4-5.5,5.5-5.5c3,0,5.5,2.4,5.5,5.5 + C19.5,14,17,16.4,14,16.4z"/> + <path d="M14,5.5C11,5.5,8.6,8,8.6,11c0,3,2.4,5.5,5.5,5.5c3,0,5.5-2.4,5.5-5.5C19.5,8,17,5.5,14,5.5z M14,15.4 + c-2.5,0-4.5-2-4.5-4.5c0-2.5,2-4.5,4.5-4.5c2.5,0,4.5,2,4.5,4.5C18.5,13.4,16.5,15.4,14,15.4z"/> + <path d="M20.9,2.8h-1.3l-1.7-2.4c-0.2-0.2-0.5-0.6-0.8-0.6h-6.3c-0.3,0-0.6,0.4-0.8,0.6L8.4,2.8h-6c-1.3,0-2.1,0.8-2.1,2.1V17 + c0,1.3,0.8,2.8,2.1,2.8h18.5c1.3,0,2.3-1.5,2.3-2.8V4.9C23.2,3.6,22.2,2.8,20.9,2.8z M2.2,17V4.9c0-0.2-0.1-0.1,0.1-0.1h3.9v13H2.4 + C2.2,17.8,2.2,17.2,2.2,17z M21.2,17c0,0.2-0.1,0.8-0.3,0.8H7.2v-13h1.7c0.3,0,0.6-0.4,0.8-0.6l1.7-2.4h5.3l1.7,2.4 + c0.2,0.2,0.5,0.6,0.8,0.6h1.8c0.2,0,0.3-0.1,0.3,0.1V17z"/> +</g> +</svg> diff --git a/examples/opengl/contextinfo.py b/examples/opengl/contextinfo.py index ef1005604..9cd22965c 100644 --- a/examples/opengl/contextinfo.py +++ b/examples/opengl/contextinfo.py @@ -109,10 +109,10 @@ colors = numpy.array([1, 0, 0, 0, 1, 0, 0, 0, 1], dtype = numpy.float32) class RenderWindow(QWindow): def __init__(self, format): super(RenderWindow, self).__init__() - self.setSurfaceType(QWindow.OpenGLSurface); - self.setFormat(format); - self.context = QOpenGLContext(self); - self.context.setFormat(self.requestedFormat()); + self.setSurfaceType(QWindow.OpenGLSurface) + self.setFormat(format) + self.context = QOpenGLContext(self) + self.context.setFormat(self.requestedFormat()) if not self.context.create(): raise Exception("Unable to create GL context") self.program = None @@ -120,12 +120,12 @@ class RenderWindow(QWindow): self.angle = 0 def initGl(self): - self.program = QOpenGLShaderProgram(self); + self.program = QOpenGLShaderProgram(self) self.vao = QOpenGLVertexArrayObject() self.vbo = QOpenGLBuffer() - format = self.context.format(); - useNewStyleShader = format.profile() == QSurfaceFormat.CoreProfile; + format = self.context.format() + useNewStyleShader = format.profile() == QSurfaceFormat.CoreProfile # Try to handle 3.0 & 3.1 that do not have the core/compatibility profile # concept 3.2+ has. This may still fail since version 150 (3.2) is # specified in the sources but it's worth a try. @@ -142,31 +142,31 @@ class RenderWindow(QWindow): if not self.program.link(): raise Exception("Could not link shaders: {}".format(self.program.log())) - self.posAttr = self.program.attributeLocation("posAttr"); - self.colAttr = self.program.attributeLocation("colAttr"); - self.matrixUniform = self.program.uniformLocation("matrix"); + self.posAttr = self.program.attributeLocation("posAttr") + self.colAttr = self.program.attributeLocation("colAttr") + self.matrixUniform = self.program.uniformLocation("matrix") - self.vbo.create(); - self.vbo.bind(); + self.vbo.create() + self.vbo.bind() self.verticesData = vertices.tobytes() self.colorsData = colors.tobytes() verticesSize = 4 * vertices.size colorsSize = 4 * colors.size - self.vbo.allocate(VoidPtr(self.verticesData), verticesSize + colorsSize); + self.vbo.allocate(VoidPtr(self.verticesData), verticesSize + colorsSize) self.vbo.write(verticesSize, VoidPtr(self.colorsData), colorsSize) - self.vbo.release(); + self.vbo.release() vaoBinder = QOpenGLVertexArrayObject.Binder(self.vao) if self.vao.isCreated(): # have VAO support, use it self.setupVertexAttribs() def setupVertexAttribs(self): - self.vbo.bind(); - self.program.setAttributeBuffer(self.posAttr, GL.GL_FLOAT, 0, 2); - self.program.setAttributeBuffer(self.colAttr, GL.GL_FLOAT, 4 * vertices.size, 3); - self.program.enableAttributeArray(self.posAttr); - self.program.enableAttributeArray(self.colAttr); - self.vbo.release(); + self.vbo.bind() + self.program.setAttributeBuffer(self.posAttr, GL.GL_FLOAT, 0, 2) + self.program.setAttributeBuffer(self.colAttr, GL.GL_FLOAT, 4 * vertices.size, 3) + self.program.enableAttributeArray(self.posAttr) + self.program.enableAttributeArray(self.colAttr) + self.vbo.release() def exposeEvent(self, event): if self.isExposed(): @@ -185,22 +185,22 @@ class RenderWindow(QWindow): functions.glClearColor(0, 0, 0, 1) self.initGl() - functions.glViewport(0, 0, self.width(), self.height()); - functions.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + functions.glViewport(0, 0, self.width(), self.height()) + functions.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) - self.program.bind(); + self.program.bind() matrix = QMatrix4x4() matrix.perspective(60, 4 / 3, 0.1, 100) matrix.translate(0, 0, -2) matrix.rotate(self.angle, 0, 1, 0) - self.program.setUniformValue(self.matrixUniform, matrix); + self.program.setUniformValue(self.matrixUniform, matrix) if self.vao.isCreated(): - self.vao.bind(); + self.vao.bind() else: # no VAO support, set the vertex attribute arrays now self.setupVertexAttribs() - functions.glDrawArrays(GL.GL_TRIANGLES, 0, 3); + functions.glDrawArrays(GL.GL_TRIANGLES, 0, 3) self.vao.release() self.program.release() diff --git a/examples/script/README.md b/examples/script/README.md new file mode 100644 index 000000000..6133f4302 --- /dev/null +++ b/examples/script/README.md @@ -0,0 +1,9 @@ +# About QtScript + +The QtScript module is deprecated since Qt 5.5, +and hence is not being distributed through our wheels. + +However, it is possible to access the module +when using a local build of PySide2 which was built +against a Qt installation containing the Qt Script module +(ALL_OPTIONAL_MODULES in `sources/pyside2/CMakeLists.txt`). diff --git a/examples/scriptableapplication/pythonutils.cpp b/examples/scriptableapplication/pythonutils.cpp index 2f7d2c2ad..f546a5a6c 100644 --- a/examples/scriptableapplication/pythonutils.cpp +++ b/examples/scriptableapplication/pythonutils.cpp @@ -54,6 +54,8 @@ #include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <QtCore/QStringList> +#include <QtCore/QTemporaryFile> +#include <QtCore/QDir> #include <sbkpython.h> #include <sbkconverter.h> @@ -122,7 +124,7 @@ bool bindAppObject(const QString &moduleName, const QString &name, return false; PyTypeObject *typeObject = SbkAppLibTypes[index]; - PyObject *po = Shiboken::Conversions::pointerToPython(reinterpret_cast<const SbkObjectType *>(typeObject), o); + PyObject *po = Shiboken::Conversions::pointerToPython(reinterpret_cast<SbkObjectType *>(typeObject), o); if (!po) { qWarning() << __FUNCTION__ << "Failed to create wrapper for" << o; return false; @@ -152,17 +154,22 @@ bool runScript(const QStringList &script) { if (init() == PythonUninitialized) return false; + + // Concatenating all the lines + QString content; + QTextStream ss(&content); + for (const QString &line: script) + ss << line << "\n"; + + // Executing the whole script as one line bool result = true; - for (const QString& lineS : script) { - const QByteArray line = lineS.toUtf8(); - if (PyRun_SimpleString(line.constData()) == -1) { - if (PyErr_Occurred()) - PyErr_Print(); - qWarning() << __FUNCTION__ << "Error at" << line; - result = false; - break; - } + const QByteArray line = content.toUtf8(); + if (PyRun_SimpleString(line.constData()) == -1) { + if (PyErr_Occurred()) + PyErr_Print(); + result = false; } + return result; } diff --git a/examples/tutorial/t10.py b/examples/tutorial/t10.py index f49faa1b4..baf3884aa 100644 --- a/examples/tutorial/t10.py +++ b/examples/tutorial/t10.py @@ -105,7 +105,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle @@ -121,7 +121,7 @@ class CannonField(QtWidgets.QWidget): force = 0 if self.currentForce == force: return - self.currentForce = force; + self.currentForce = force self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce) def paintEvent(self, event): diff --git a/examples/tutorial/t11.py b/examples/tutorial/t11.py index 46e24e0d5..b028fc22e 100644 --- a/examples/tutorial/t11.py +++ b/examples/tutorial/t11.py @@ -112,7 +112,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle @@ -128,7 +128,7 @@ class CannonField(QtWidgets.QWidget): force = 0 if self.currentForce == force: return - self.currentForce = force; + self.currentForce = force self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce) @QtCore.Slot() @@ -162,7 +162,7 @@ class CannonField(QtWidgets.QWidget): self.paintShot(painter) def paintShot(self, painter): - painter.setPen(QtCore.Qt.NoPen); + painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtCore.Qt.black) painter.drawRect(self.shotRect()) diff --git a/examples/tutorial/t12.py b/examples/tutorial/t12.py index a3e1a6cf3..945edbd8e 100644 --- a/examples/tutorial/t12.py +++ b/examples/tutorial/t12.py @@ -134,7 +134,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle @@ -150,7 +150,7 @@ class CannonField(QtWidgets.QWidget): force = 0 if self.currentForce == force: return - self.currentForce = force; + self.currentForce = force self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce) @QtCore.Slot() @@ -201,7 +201,7 @@ class CannonField(QtWidgets.QWidget): self.paintTarget(painter) def paintShot(self, painter): - painter.setPen(QtCore.Qt.NoPen); + painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtCore.Qt.black) painter.drawRect(self.shotRect()) diff --git a/examples/tutorial/t13.py b/examples/tutorial/t13.py index a26db0734..706b8a52c 100644 --- a/examples/tutorial/t13.py +++ b/examples/tutorial/t13.py @@ -139,7 +139,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle @@ -155,7 +155,7 @@ class CannonField(QtWidgets.QWidget): force = 0 if self.currentForce == force: return - self.currentForce = force; + self.currentForce = force self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce) @QtCore.Slot() @@ -229,7 +229,7 @@ class CannonField(QtWidgets.QWidget): self.paintTarget(painter) def paintShot(self, painter): - painter.setPen(QtCore.Qt.NoPen); + painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtCore.Qt.black) painter.drawRect(self.shotRect()) diff --git a/examples/tutorial/t14.py b/examples/tutorial/t14.py index caf6d183f..a7a4a0595 100644 --- a/examples/tutorial/t14.py +++ b/examples/tutorial/t14.py @@ -140,7 +140,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle @@ -156,7 +156,7 @@ class CannonField(QtWidgets.QWidget): force = 0 if self.currentForce == force: return - self.currentForce = force; + self.currentForce = force self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce) @QtCore.Slot() @@ -234,7 +234,7 @@ class CannonField(QtWidgets.QWidget): def mouseReleaseEvent(self, event): if event.button() == QtCore.Qt.LeftButton: - self.barrelPressed = False; + self.barrelPressed = False def paintEvent(self, event): painter = QtGui.QPainter(self) @@ -252,7 +252,7 @@ class CannonField(QtWidgets.QWidget): self.paintTarget(painter) def paintShot(self, painter): - painter.setPen(QtCore.Qt.NoPen); + painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtCore.Qt.black) painter.drawRect(self.shotRect()) diff --git a/examples/tutorial/t5.py b/examples/tutorial/t5.py index f9f657fac..783fa73d2 100644 --- a/examples/tutorial/t5.py +++ b/examples/tutorial/t5.py @@ -66,10 +66,10 @@ class MyWidget(QtWidgets.QWidget): lcd, QtCore.SLOT("display(int)")) layout = QtWidgets.QVBoxLayout() - layout.addWidget(quit); - layout.addWidget(lcd); - layout.addWidget(slider); - self.setLayout(layout); + layout.addWidget(quit) + layout.addWidget(lcd) + layout.addWidget(slider) + self.setLayout(layout) app = QtWidgets.QApplication(sys.argv) diff --git a/examples/tutorial/t8.py b/examples/tutorial/t8.py index 0c682df19..e203ed8a2 100644 --- a/examples/tutorial/t8.py +++ b/examples/tutorial/t8.py @@ -103,7 +103,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle diff --git a/examples/tutorial/t9.py b/examples/tutorial/t9.py index dc2106d9e..d4640744b 100644 --- a/examples/tutorial/t9.py +++ b/examples/tutorial/t9.py @@ -103,7 +103,7 @@ class CannonField(QtWidgets.QWidget): if angle < 5: angle = 5 if angle > 70: - angle = 70; + angle = 70 if self.currentAngle == angle: return self.currentAngle = angle diff --git a/examples/webenginequick/browser.qml b/examples/webenginequick/browser.qml new file mode 100644 index 000000000..781453863 --- /dev/null +++ b/examples/webenginequick/browser.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt for Python examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import QtWebEngine 1.0 + +Window { + width: 1024 + height: 768 + visible: true + WebEngineView { + anchors.fill: parent + url: "https://www.qt.io" + } +} diff --git a/examples/webenginequick/quicknanobrowser.py b/examples/webenginequick/quicknanobrowser.py new file mode 100644 index 000000000..24e58eada --- /dev/null +++ b/examples/webenginequick/quicknanobrowser.py @@ -0,0 +1,59 @@ +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Qt for Python examples of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of The Qt Company Ltd nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +"""PySide2 WebEngine QtQuick 2 Example""" + +import os +from PySide2.QtCore import QUrl +from PySide2.QtQml import QQmlApplicationEngine +from PySide2.QtWidgets import QApplication +from PySide2.QtWebEngine import QtWebEngine + +def main(): + app = QApplication([]) + QtWebEngine.initialize() + engine = QQmlApplicationEngine() + qml_file_path = os.path.join(os.path.dirname(__file__), 'browser.qml') + qml_url = QUrl.fromLocalFile(os.path.abspath(qml_file_path)) + engine.load(qml_url) + app.exec_() + +if __name__ == '__main__': + main() diff --git a/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py b/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py index 01a69b921..6bd2b4586 100644 --- a/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py +++ b/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py @@ -122,6 +122,7 @@ def _serialize_model(model, directory): # Bookmarks as a tree view to be used in a dock widget with # functionality to persist and populate tool bars and menus. class BookmarkWidget(QTreeView): + """Provides a tree view to manage the bookmarks.""" open_bookmark = QtCore.Signal(QUrl) open_bookmark_in_new_tab = QtCore.Signal(QUrl) diff --git a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py index d9263be08..d85b8ad3d 100644 --- a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py +++ b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py @@ -50,6 +50,7 @@ from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem, QWebEnginePage, QWebEngineProfile) class BrowserTabWidget(QTabWidget): + """Enables having several tabs with QWebEngineView.""" url_changed = QtCore.Signal(QUrl) enabled_changed = QtCore.Signal(QWebEnginePage.WebAction, bool) diff --git a/examples/webenginewidgets/tabbedbrowser/downloadwidget.py b/examples/webenginewidgets/tabbedbrowser/downloadwidget.py index 030dfc14b..437c534ec 100644 --- a/examples/webenginewidgets/tabbedbrowser/downloadwidget.py +++ b/examples/webenginewidgets/tabbedbrowser/downloadwidget.py @@ -48,7 +48,7 @@ from PySide2.QtWebEngineWidgets import QWebEngineDownloadItem # A QProgressBar with context menu for displaying downloads in a QStatusBar. class DownloadWidget(QProgressBar): - + """Lets you track progress of a QWebEngineDownloadItem.""" finished = QtCore.Signal() remove_requested = QtCore.Signal() diff --git a/examples/webenginewidgets/tabbedbrowser/main.py b/examples/webenginewidgets/tabbedbrowser/main.py index 12efdcd5c..9fe98da65 100644 --- a/examples/webenginewidgets/tabbedbrowser/main.py +++ b/examples/webenginewidgets/tabbedbrowser/main.py @@ -60,6 +60,7 @@ from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem, QWebEnginePage, main_windows = [] def create_main_window(): + """Creates a MainWindow using 75% of the available screen resolution.""" main_win = MainWindow() main_windows.append(main_win) available_geometry = app.desktop().availableGeometry(main_win) @@ -68,11 +69,14 @@ def create_main_window(): return main_win def create_main_window_with_browser(): + """Creates a MainWindow with a BrowserTabWidget.""" main_win = create_main_window() return main_win.add_browser_tab() class MainWindow(QMainWindow): - + """Provides the parent window that includes the BookmarkWidget, + BrowserTabWidget, and a DownloadWidget, to offer the complete + web browsing experience.""" def __init__(self): super(MainWindow, self).__init__() diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py index f50c99378..e390cfcee 100755 --- a/examples/widgets/animation/animatedtiles/animatedtiles.py +++ b/examples/widgets/animation/animatedtiles/animatedtiles.py @@ -229,7 +229,7 @@ if __name__ == '__main__': group = QtCore.QParallelAnimationGroup() for i, item in enumerate(items): - anim = QtCore.QPropertyAnimation(item, 'pos') + anim = QtCore.QPropertyAnimation(item, b'pos') anim.setDuration(750 + i * 25) anim.setEasingCurve(QtCore.QEasingCurve.InOutBack) group.addAnimation(anim) diff --git a/examples/widgets/animation/appchooser/appchooser.py b/examples/widgets/animation/appchooser/appchooser.py index 67550ab4e..862e2bef4 100755 --- a/examples/widgets/animation/appchooser/appchooser.py +++ b/examples/widgets/animation/appchooser/appchooser.py @@ -79,7 +79,7 @@ def createStates(objects, selectedRect, parent): def createAnimations(objects, machine): for obj in objects: - animation = QtCore.QPropertyAnimation(obj, 'geometry', obj) + animation = QtCore.QPropertyAnimation(obj, b'geometry', obj) machine.addDefaultAnimation(animation) diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py index 17377e83d..8bb742542 100644 --- a/examples/widgets/animation/easing/easing.py +++ b/examples/widgets/animation/easing/easing.py @@ -135,7 +135,7 @@ class Window(QtWidgets.QWidget): self.m_scene.addItem(self.m_item.pixmap_item) self.m_ui.graphicsView.setScene(self.m_scene) - self.m_anim = Animation(self.m_item, 'pos') + self.m_anim = Animation(self.m_item, b'pos') self.m_anim.setEasingCurve(QtCore.QEasingCurve.OutBounce) self.m_ui.easingCurvePicker.setCurrentRow(int(QtCore.QEasingCurve.OutBounce)) @@ -173,7 +173,7 @@ class Window(QtWidgets.QWidget): painter.drawLine(0, xAxis, self.m_iconSize.width(), xAxis) painter.drawLine(yAxis, 0, yAxis, self.m_iconSize.height()) - curveScale = self.m_iconSize.height() / 2.0; + curveScale = self.m_iconSize.height() / 2.0 painter.setPen(QtCore.Qt.NoPen) diff --git a/examples/widgets/animation/states/states.py b/examples/widgets/animation/states/states.py index 6b31922cb..6cf1597dd 100755 --- a/examples/widgets/animation/states/states.py +++ b/examples/widgets/animation/states/states.py @@ -191,71 +191,71 @@ if __name__ == '__main__': t1 = state1.addTransition(button.clicked, state2) animation1SubGroup = QtCore.QSequentialAnimationGroup() animation1SubGroup.addPause(250) - animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state1)) + animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state1)) t1.addAnimation(animation1SubGroup) - t1.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state1)) - t1.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state1)) + t1.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state1)) t2 = state2.addTransition(button.clicked, state3) - t2.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state2)) - t2.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state2)) + t2.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state2)) t3 = state3.addTransition(button.clicked, state1) - t3.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state3)) - t3.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state3)) + t3.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state3)) machine.start() diff --git a/examples/widgets/draganddrop/draggabletext/draggabletext.py b/examples/widgets/draganddrop/draggabletext/draggabletext.py index 67e988714..d2bcdf5ae 100755 --- a/examples/widgets/draganddrop/draggabletext/draggabletext.py +++ b/examples/widgets/draganddrop/draggabletext/draggabletext.py @@ -64,7 +64,7 @@ class DragLabel(QLabel): mimeData = QMimeData() mimeData.setText(self.text()) mimeData.setData('application/x-hotspot', - '%d %d' % (hotSpot.x(), hotSpot.y())) + b'%d %d' % (hotSpot.x(), hotSpot.y())) pixmap = QPixmap(self.size()) self.render(pixmap) diff --git a/examples/widgets/graphicsview/collidingmice/collidingmice.py b/examples/widgets/graphicsview/collidingmice/collidingmice.py index 575ecc1f1..8bff64bc3 100644 --- a/examples/widgets/graphicsview/collidingmice/collidingmice.py +++ b/examples/widgets/graphicsview/collidingmice/collidingmice.py @@ -90,7 +90,7 @@ class Mouse(QtWidgets.QGraphicsItem): def shape(self): path = QtGui.QPainterPath() path.addRect(-10, -20, 20, 40) - return path; + return path def paint(self, painter, option, widget): # Body. @@ -133,7 +133,7 @@ class Mouse(QtWidgets.QGraphicsItem): if lineToCenter.length() > 150: angleToCenter = math.acos(lineToCenter.dx() / lineToCenter.length()) if lineToCenter.dy() < 0: - angleToCenter = Mouse.TwoPi - angleToCenter; + angleToCenter = Mouse.TwoPi - angleToCenter angleToCenter = Mouse.normalizeAngle((Mouse.Pi - angleToCenter) + Mouse.Pi / 2) if angleToCenter < Mouse.Pi and angleToCenter > Mouse.Pi / 4: diff --git a/examples/widgets/graphicsview/elasticnodes.py b/examples/widgets/graphicsview/elasticnodes.py index f013156d7..f640ab60c 100755 --- a/examples/widgets/graphicsview/elasticnodes.py +++ b/examples/widgets/graphicsview/elasticnodes.py @@ -131,7 +131,7 @@ class Edge(QtWidgets.QGraphicsItem): sourceArrowP1 = self.sourcePoint + QtCore.QPointF(math.sin(angle + Edge.Pi / 3) * self.arrowSize, math.cos(angle + Edge.Pi / 3) * self.arrowSize) sourceArrowP2 = self.sourcePoint + QtCore.QPointF(math.sin(angle + Edge.Pi - Edge.Pi / 3) * self.arrowSize, - math.cos(angle + Edge.Pi - Edge.Pi / 3) * self.arrowSize); + math.cos(angle + Edge.Pi - Edge.Pi / 3) * self.arrowSize) destArrowP1 = self.destPoint + QtCore.QPointF(math.sin(angle - Edge.Pi / 3) * self.arrowSize, math.cos(angle - Edge.Pi / 3) * self.arrowSize) destArrowP2 = self.destPoint + QtCore.QPointF(math.sin(angle - Edge.Pi + Edge.Pi / 3) * self.arrowSize, diff --git a/examples/widgets/layouts/dynamiclayouts.py b/examples/widgets/layouts/dynamiclayouts.py index fe46c053a..77750ee10 100644 --- a/examples/widgets/layouts/dynamiclayouts.py +++ b/examples/widgets/layouts/dynamiclayouts.py @@ -86,27 +86,27 @@ class Dialog(QDialog): def buttonsOrientationChanged(self, index): - self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint); - self.setMinimumSize(0, 0); + self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint) + self.setMinimumSize(0, 0) orientation = Qt.Orientation(int(self.buttonsOrientationComboBox.itemData(index))) if orientation == self.buttonBox.orientation(): return - self.mainLayout.removeWidget(self.buttonBox); + self.mainLayout.removeWidget(self.buttonBox) spacing = self.mainLayout.spacing() - oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing); + oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing) self.buttonBox.setOrientation(orientation) newSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing) if orientation == Qt.Horizontal: - self.mainLayout.addWidget(self.buttonBox, 2, 0); + self.mainLayout.addWidget(self.buttonBox, 2, 0) self.resize(self.size() + QSize(-oldSizeHint.width(), newSizeHint.height())) else: - self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1); + self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1) self.resize(self.size() + QSize(newSizeHint.width(), -oldSizeHint.height())) self.mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint) diff --git a/examples/widgets/mainwindows/application/application.py b/examples/widgets/mainwindows/application/application.py index be0dc992e..78a1f9942 100755 --- a/examples/widgets/mainwindows/application/application.py +++ b/examples/widgets/mainwindows/application/application.py @@ -161,7 +161,7 @@ class MainWindow(QtWidgets.QMainWindow): self.fileMenu.addAction(self.openAct) self.fileMenu.addAction(self.saveAct) self.fileMenu.addAction(self.saveAsAct) - self.fileMenu.addSeparator(); + self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAct) self.editMenu = self.menuBar().addMenu("&Edit") @@ -243,7 +243,7 @@ class MainWindow(QtWidgets.QMainWindow): outf << self.textEdit.toPlainText() QtWidgets.QApplication.restoreOverrideCursor() - self.setCurrentFile(fileName); + self.setCurrentFile(fileName) self.statusBar().showMessage("File saved", 2000) return True diff --git a/examples/widgets/richtext/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter.py index 6a431c3f9..83621ca82 100755 --- a/examples/widgets/richtext/syntaxhighlighter.py +++ b/examples/widgets/richtext/syntaxhighlighter.py @@ -189,7 +189,7 @@ class Highlighter(QtGui.QSyntaxHighlighter): self.setFormat(startIndex, commentLength, self.multiLineCommentFormat) startIndex = self.commentStartExpression.indexIn(text, - startIndex + commentLength); + startIndex + commentLength) if __name__ == '__main__': diff --git a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py index 841943292..32adb70c7 100644 --- a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py +++ b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py @@ -75,7 +75,7 @@ class MainWindow(QtWidgets.QMainWindow): if fileName!="": inFile = QtCore.QFile(fileName) if inFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text): - self.editor.setPlainText(unicode(inFile.readAll())) + self.editor.setPlainText(str(inFile.readAll())) def setupEditor(self): variableFormat = QtGui.QTextCharFormat() diff --git a/examples/xmlpatterns/schema/schema.py b/examples/xmlpatterns/schema/schema.py index a10cc32ce..4a24e4f30 100755 --- a/examples/xmlpatterns/schema/schema.py +++ b/examples/xmlpatterns/schema/schema.py @@ -61,7 +61,7 @@ except NameError: # Python v3. def encode_utf8(ba): - return str(ba, encoding='utf8') + return str(ba.data(), encoding='utf8') def decode_utf8(qs): return QtCore.QByteArray(bytes(qs, encoding='utf8')) |