1
0

use ctypes to access the zbar library

This commit is contained in:
ThomasV
2017-02-17 20:56:38 +01:00
parent 90464b6ac1
commit d99855f060
4 changed files with 49 additions and 39 deletions

View File

@@ -2001,7 +2001,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
def read_tx_from_qrcode(self):
from electrum import qrscanner
try:
data = qrscanner.scan_qr(self.config)
data = qrscanner.scan_barcode(self.config.get_video_device())
except BaseException as e:
self.show_error(str(e))
return
@@ -2517,9 +2517,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
#combo.addItem("Manually specify a device", config.get("video_device"))
index = qr_combo.findData(self.config.get("video_device"))
qr_combo.setCurrentIndex(index)
msg = _("Install the zbar package to enable this.\nOn linux, type: 'apt-get install python-zbar'")
msg = _("Install the zbar package to enable this.")
qr_label = HelpLabel(_('Video Device') + ':', msg)
qr_combo.setEnabled(qrscanner.zbar is not None)
qr_combo.setEnabled(qrscanner.libzbar is not None)
on_video_device = lambda x: self.config.set_key("video_device", str(qr_combo.itemData(x).toString()), True)
qr_combo.currentIndexChanged.connect(on_video_device)
gui_widgets.append((qr_label, qr_combo))

View File

@@ -49,12 +49,12 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
def qr_input(self):
from electrum import qrscanner, get_config
try:
data = qrscanner.scan_qr(get_config())
data = qrscanner.scan_barcode(get_config().get_video_device())
except BaseException as e:
self.show_error(str(e))
return ""
data = ''
if type(data) != str:
return
data = ''
self.setText(data)
return data