electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 311a91c03c95b4fe2a503c9968ebd53d016ed6be
parent bfbd6f0e9df5d05f9021e43168ef4e6fce95c60d
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 24 Oct 2014 17:11:05 +0200

init qrscanner processor in scan_qr

Diffstat:
Mgui/qt/main_window.py | 6------
Mgui/qt/qrtextedit.py | 8+-------
Mlib/qrscanner.py | 19++++++++-----------
3 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -2144,12 +2144,6 @@ class ElectrumWindow(QMainWindow): def read_tx_from_qrcode(self): from electrum import qrscanner - if qrscanner.proc is None: - try: - qrscanner.init(self.config) - except Exception, e: - QMessageBox.warning(self, _('Error'), _(e), _('OK')) - return try: data = qrscanner.scan_qr(self.config) except BaseException, e: diff --git a/gui/qt/qrtextedit.py b/gui/qt/qrtextedit.py @@ -53,17 +53,11 @@ class ScanQRTextEdit(QRTextEdit): def qr_input(self): from electrum import qrscanner - if qrscanner.proc is None: - try: - qrscanner.init(self.win.config) - except Exception, e: - QMessageBox.warning(self, _('Error'), _(e), _('OK')) - return try: data = qrscanner.scan_qr(self.win.config) except BaseException, e: QMessageBox.warning(self, _('Error'), _(e), _('OK')) - return + return "" if type(data) != str: return self.setText(data) diff --git a/lib/qrscanner.py b/lib/qrscanner.py @@ -8,21 +8,18 @@ except ImportError: proc = None -def init(config): - if not zbar: - raise BaseException("\n".join([_("Cannot start QR scanner."),_("The zbar package is not available."),_("On Linux, try 'sudo apt-get install python-zbar'")])) - device = config.get("video_device", "default") - if device == 'default': - device = '' - global proc - proc = zbar.Processor() - proc.init(video_device=device) -def scan_qr(self): +def scan_qr(config): + global proc if not zbar: raise BaseException("\n".join([_("Cannot start QR scanner."),_("The zbar package is not available."),_("On Linux, try 'sudo apt-get install python-zbar'")])) if proc is None: - raise BaseException("Start proc first") + device = config.get("video_device", "default") + if device == 'default': + device = '' + proc = zbar.Processor() + proc.init(video_device=device) + proc.visible = True while True: try: