commit 56588de5d92f8128b8eea7605b16b787cddc9a7b
parent df3187d9a91f856bb4053a786cc683b703b3683d
Author: ecdsa <ecdsa@github>
Date: Mon, 4 Mar 2013 11:01:09 +0100
slightly smarter qr code widget that does not need size parameter
Diffstat:
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/gui/gui_classic.py b/gui/gui_classic.py
@@ -1231,7 +1231,7 @@ class ElectrumWindow(QMainWindow):
main_text.setText(self.wallet.get_master_public_key())
main_text.setReadOnly(True)
main_text.setMaximumHeight(170)
- qrw = QRCodeWidget(self.wallet.get_master_public_key(), 6)
+ qrw = QRCodeWidget(self.wallet.get_master_public_key())
ok_button = QPushButton(_("OK"))
ok_button.setDefault(True)
diff --git a/gui/qrcodewidget.py b/gui/qrcodewidget.py
@@ -8,12 +8,11 @@ import bmp, pyqrnative
class QRCodeWidget(QWidget):
- def __init__(self, data = None, size=4):
+ def __init__(self, data = None):
QWidget.__init__(self)
self.setMinimumSize(210, 210)
self.addr = None
self.qr = None
- self.size = size
if data:
self.set_addr(data)
self.update_qr()
@@ -26,12 +25,15 @@ class QRCodeWidget(QWidget):
def update_qr(self):
if self.addr and not self.qr:
- self.qr = pyqrnative.QRCode(self.size, pyqrnative.QRErrorCorrectLevel.L)
- self.qr.addData(self.addr)
- try:
- self.qr.make()
- except:
- self.qr=None
+ for size in [4,5,6]:
+ try:
+ self.qr = pyqrnative.QRCode(size, pyqrnative.QRErrorCorrectLevel.L)
+ self.qr.addData(self.addr)
+ self.qr.make()
+ break
+ except:
+ self.qr=None
+ continue
self.update()
def paintEvent(self, e):