[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kajongg] src: PyQt5 for Python3: Some things now want bytes instead of str
From: Wolfgang Rohdewald <wolfgang () rohdewald ! de>
Date: 2016-12-03 9:17:40
Message-ID: E1cD6Rw-0002UT-R2 () code ! kde ! org
[Download RAW message or body]
Git commit d252f6304424dd65edc80f51653201af6451dc7b by Wolfgang Rohdewald.
Committed on 03/12/2016 at 09:16.
Pushed by wrohdewald into branch 'master'.
PyQt5 for Python3: Some things now want bytes instead of str
M +6 -2 src/animation.py
M +7 -2 src/statesaver.py
https://commits.kde.org/kajongg/d252f6304424dd65edc80f51653201af6451dc7b
diff --git a/src/animation.py b/src/animation.py
index bbd6abc..a653ca9 100644
--- a/src/animation.py
+++ b/src/animation.py
@@ -24,7 +24,7 @@ import types
from twisted.internet.defer import Deferred, succeed
from qt import QPropertyAnimation, QParallelAnimationGroup, \
- QAbstractAnimation, QEasingCurve, QVariant
+ QAbstractAnimation, QEasingCurve, QVariant, usingQt5
from common import Internal, Debug, isAlive, isPython3, nativeString
from log import logDebug
@@ -37,7 +37,11 @@ class Animation(QPropertyAnimation):
nextAnimations = []
def __init__(self, uiTile, propName, endValue, parent=None):
- QPropertyAnimation.__init__(self, uiTile, propName, parent)
+ pName = propName
+ if isPython3 and usingQt5:
+ # in this case they want bytes
+ pName = pName.encode()
+ QPropertyAnimation.__init__(self, uiTile, pName, parent)
QPropertyAnimation.setEndValue(self, endValue)
duration = Internal.Preferences.animationDuration()
self.setDuration(duration)
diff --git a/src/statesaver.py b/src/statesaver.py
index 11ed19f..5e1debe 100644
--- a/src/statesaver.py
+++ b/src/statesaver.py
@@ -19,8 +19,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
from qt import QString, QObject, QByteArray, QEvent, QSplitter, QHeaderView
+from qt import usingQt5
-from common import Internal, isAlive, english
+from common import Internal, isAlive, english, isPython3
class StateSaver(QObject):
@@ -51,7 +52,11 @@ class StateSaver(QObject):
@staticmethod
def __restore(widget, name):
"""decode the saved string"""
- state = QByteArray.fromHex(Internal.Preferences[name])
+ if usingQt5 and isPython3:
+ # Qt5 fromHex expects bytes, not str
+ state = QByteArray.fromHex(Internal.Preferences[name].encode())
+ else:
+ state = QByteArray.fromHex(Internal.Preferences[name])
if state:
if name.endswith('State'):
widget.restoreState(state)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic