Browse Source

fixedSize qrcode widget

283
ThomasV 11 years ago
parent
commit
e5b44bacda
  1. 2
      gui/qt/main_window.py
  2. 10
      gui/qt/qrcodewidget.py

2
gui/qt/main_window.py

@ -687,7 +687,7 @@ class ElectrumWindow(QMainWindow):
grid.addWidget(clear_button, 3, 2)
grid.setRowStretch(4, 1)
self.receive_qr = QRCodeWidget()
self.receive_qr = QRCodeWidget(fixedSize=200)
grid.addWidget(self.receive_qr, 0, 4, 5, 2)
grid.setRowStretch(5, 1)

10
gui/qt/qrcodewidget.py

@ -13,10 +13,13 @@ from electrum.i18n import _
class QRCodeWidget(QWidget):
def __init__(self, data = None):
def __init__(self, data = None, fixedSize=False):
QWidget.__init__(self)
self.data = None
self.qr = None
self.fixedSize=fixedSize
if fixedSize:
self.setFixedSize(fixedSize, fixedSize)
self.setData(data)
@ -26,8 +29,9 @@ class QRCodeWidget(QWidget):
if self.data:
self.qr = qrcode.QRCode()
self.qr.add_data(self.data)
k = len(self.qr.get_matrix())
self.setMinimumSize(k*5,k*5)
if not self.fixedSize:
k = len(self.qr.get_matrix())
self.setMinimumSize(k*5,k*5)
else:
self.qr = None

Loading…
Cancel
Save