Browse Source

slightly smarter qr code widget that does not need size parameter

283
ecdsa 12 years ago
parent
commit
56588de5d9
  1. 2
      gui/gui_classic.py
  2. 18
      gui/qrcodewidget.py

2
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)

18
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):

Loading…
Cancel
Save