From b4c5b996a1af63ce80adeb7574e592936bbf2f4a Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Wed, 3 Oct 2018 17:58:46 +0200 Subject: [PATCH] Fix Qt5/4 import strategy. - Try Qt5 before Qt4. - Handle all exceptions (a ValueError is thrown if the wrong Qt was imported earlier) --- trezorlib/qt/pinmatrix.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/trezorlib/qt/pinmatrix.py b/trezorlib/qt/pinmatrix.py index 19ae2db624..bc42814722 100644 --- a/trezorlib/qt/pinmatrix.py +++ b/trezorlib/qt/pinmatrix.py @@ -18,20 +18,6 @@ import math import sys try: - from PyQt4.QtGui import ( - QPushButton, - QLineEdit, - QSizePolicy, - QRegExpValidator, - QLabel, - QApplication, - QWidget, - QGridLayout, - QVBoxLayout, - QHBoxLayout, - ) - from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt, QT_VERSION_STR -except ImportError: from PyQt5.QtWidgets import ( QPushButton, QLineEdit, @@ -46,6 +32,20 @@ except ImportError: from PyQt5.QtGui import QRegExpValidator from PyQt5.QtCore import QRegExp, Qt from PyQt5.Qt import QT_VERSION_STR +except Exception: + from PyQt4.QtGui import ( + QPushButton, + QLineEdit, + QSizePolicy, + QRegExpValidator, + QLabel, + QApplication, + QWidget, + QGridLayout, + QVBoxLayout, + QHBoxLayout, + ) + from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt, QT_VERSION_STR class PinButton(QPushButton):