init qrscanner processor in scan_qr
This commit is contained in:
parent
bfbd6f0e9d
commit
311a91c03c
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue