From 0ef0e6b020de12ae75afcd1123ec966d8c97d1ef Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 13 Mar 2018 13:39:35 +0200 Subject: [PATCH] Added docstrings. Removed unused method Image.save(). --- src/plugins/menu_qrcode.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/menu_qrcode.py b/src/plugins/menu_qrcode.py index bd73b3ab..3831e89b 100644 --- a/src/plugins/menu_qrcode.py +++ b/src/plugins/menu_qrcode.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +""" +A menu plugin showing QR-Code for bitmessage address in modal dialog. +""" from PyQt4 import QtGui, QtCore import qrcode @@ -8,6 +11,7 @@ from pybitmessage.tr import _translate # http://stackoverflow.com/questions/20452486 class Image(qrcode.image.base.BaseImage): + """Image output class for qrcode using QPainter""" def __init__(self, border, width, box_size): self.border = border self.width = width @@ -18,9 +22,11 @@ class Image(qrcode.image.base.BaseImage): self._image.fill(QtCore.Qt.white) def pixmap(self): + """Get image pixmap""" return QtGui.QPixmap.fromImage(self._image) def drawrect(self, row, col): + """Draw a single rectangle - implementation""" painter = QtGui.QPainter(self._image) painter.fillRect( (col + self.border) * self.box_size, @@ -28,12 +34,9 @@ class Image(qrcode.image.base.BaseImage): self.box_size, self.box_size, QtCore.Qt.black) - def save(self, stream, kind=None): - pass - class QRCodeDialog(QtGui.QDialog): - + """The dialog""" def __init__(self, parent): super(QRCodeDialog, self).__init__(parent) self.image = QtGui.QLabel(self) @@ -55,9 +58,11 @@ class QRCodeDialog(QtGui.QDialog): self.retranslateUi() def retranslateUi(self): + """A conventional Qt Designer method for dynamic l10n""" self.setWindowTitle(_translate("QRCodeDialog", "QR-code")) def render(self, text): + """Draw QR-code and address in labels""" self.label.setText(text) self.image.setPixmap( qrcode.make(text, image_factory=Image).pixmap()) @@ -65,7 +70,9 @@ class QRCodeDialog(QtGui.QDialog): def connect_plugin(form): + """Plugin entry point""" def on_action_ShowQR(): + """A slot for popup menu action""" try: dialog = form.qrcode_dialog except AttributeError: