Added docstrings. Removed unused method Image.save().
This commit is contained in:
parent
0ddc56e83a
commit
0ef0e6b020
|
@ -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:
|
||||
|
|
Reference in New Issue
Block a user