summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-06-04 16:18:28 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-06-05 07:10:07 +0000
commit75fbc6de0389b7220381e386740051ea0bf97e9b (patch)
tree29ebbb8e58133704e36879b15b41d4f24e6ad369
parentd059b89abf24159205c4b7d9d59cddfd47a42a66 (diff)
Adapt examples to proper QByteArray constructor
After correcting the QByteArray behavior, the available constructors are constraint to bytes, bytearrays, and others QByteArrays. The modified lines are methods that use the modified argument as a QByteArray (interally), that is why we now we transform them: "test value" -> b"test value" Bytes are Python 2 and 3 compatible, so it does not affect the version. The only different change is inside `schema.py` where a change was needed to encode a QByteArray into utf-8. Since this is outside our automated test, I manually test it with Python 2.7.15 and 3.6.3 on Linux. Task-number: PYSIDE-669 Change-Id: I8c12533b482150f4aee3d813dc127eb6b819549b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--examples/3d/simple3d.py2
-rwxr-xr-xexamples/widgets/animation/animatedtiles/animatedtiles.py2
-rwxr-xr-xexamples/widgets/animation/appchooser/appchooser.py2
-rw-r--r--examples/widgets/animation/easing/easing.py2
-rwxr-xr-xexamples/widgets/animation/states/states.py120
-rwxr-xr-xexamples/widgets/draganddrop/draggabletext/draggabletext.py2
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py2
-rwxr-xr-xexamples/xmlpatterns/schema/schema.py2
8 files changed, 67 insertions, 67 deletions
diff --git a/examples/3d/simple3d.py b/examples/3d/simple3d.py
index 3cfa39a0..e4b06132 100644
--- a/examples/3d/simple3d.py
+++ b/examples/3d/simple3d.py
@@ -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/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py
index f50c9937..e390cfce 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 67550ab4..862e2bef 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 17377e83..6a37d46d 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))
diff --git a/examples/widgets/animation/states/states.py b/examples/widgets/animation/states/states.py
index 6b31922c..6cf1597d 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 67e98871..d2bcdf5a 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/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
index 84194329..32adb70c 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 a10cc32c..4a24e4f3 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'))