XVKBD를 사용하여 바코드를 읽습니다. Enter 키를 비활성화하는 방법은 무엇입니까?
-
12-09-2019 - |
문제
Zbarcam을 사용하여 웹 캠의 웹캠에서 바코드를 읽고 있습니다. 그러나 Zbarcam이 마지막에 a n을 표시하기 때문에 내 양식이 제출됩니다.
여기에 내가 사용하는 것은 다음과 같습니다.
read_one.py
#!/usr/bin/python
from sys import argv
import zbar
import webbrowser
# create a Processor
proc = zbar.Processor()
# configure the Processor
proc.parse_config('enable')
# initialize the Processor
device = '/dev/video0'
if len(argv) > 1:
device = argv[1]
proc.init(device)
# enable the preview window
proc.visible = True
# read at least one barcode (or until window closed)
proc.process_one()
# hide the preview window
proc.visible = False
# extract results
for symbol in proc.results:
# do something useful with results
print symbol.data
keyboard.sh
python read_one.py | xvkbd -file -
바코드를 XVKBD로 보내기 전에 ' n'을 제거하거나 XVKBD에서 Enter 키를 비활성화하려면 어떻게해야합니까?
해결책
이 시도:
printf "$(python read_one.py)" | xvkbd -file -
다른 팁
Enter를 제거하려면 :
print symbol.data.strip()
그러나 그렇게하는 배관 가능한 프로그램은 일종의 불쾌합니다. 프로그램에서 XVKBD로 직접 보낼 수 있습니다 (Args에서 문자열을 전달하는 데 상관없이 파일이 필요하지 않음) :
import subprocess # at appropriate place
subprocess.call(['xvkbd', '-text', symbol.data.strip()])
이것은 또한 다른 쉘과 스크립트를 피할 수 있습니다.
제휴하지 않습니다 StackOverflow