本文整理汇总了Python中qrtools.QR类的典型用法代码示例。如果您正苦于以下问题:Python QR类的具体用法?Python QR怎么用?Python QR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qrencode
def qrencode(self):
text = [
unicode(self.textEdit.toPlainText()),
unicode(self.urlEdit.text()),
( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ),
( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ),
unicode(self.telephoneEdit.text()),
]
level = (u'L',u'M',u'Q',u'H')
data_type = (u'text',u'url',u'emailmessage',u'sms',u'telephone')
if text[self.tabs.currentIndex()]:
qr = QR(pixel_size = unicode(self.pixelSize.value()),
data=text[self.tabs.currentIndex()],
level=unicode(level[self.ecLevel.currentIndex()]),
margin_size=unicode(self.marginSize.value()),
data_type=unicode(data_type[self.tabs.currentIndex()]),
)
if qr.encode() == 0:
self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
self.saveButton.setEnabled(True)
else:
print >>sys.stderr, u"ERROR: Something went wrong while trying to generate de qrcode."
else:
self.saveButton.setEnabled(False)
示例2: scanadd
def scanadd(name):
myCode = QR(filename=name)
if myCode.decode():
if myCode.data_type == "text":
print "worked"
retval=""
add = False
start = True
for x in myCode.data:
if x in "13" and start:
add = True
start = False
retval+=x
elif add and x in "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ":
retval+=x
else:
add=False
print "raw",myCode.data
return retval
#aystit(retval, amt)
else:
print "That isn't text you tricky trickster"
else:
print "I can't decode that. Sorry."
示例3: generate
def generate(codes = range(20), width=2.0, cols = 5):
width_str = '%fcm' % width
tex_figs = ''
c_strs = []
f_strs = []
for c in codes:
c_str = '%06d' % c
qr = QR(data = url_fmt % c)
img_filename = img_dir + '/%s.png' % c_str
qr.encode(img_filename)
c_strs.append(c_str)
f_strs.append(figure_fmt % (width_str, img_filename))
elts = []
for i in range(0,len(codes),cols):
elts.append(c_strs[i:i+cols])
elts.append(f_strs[i:i+cols])
tex_file = open(tex_filename, 'w')
tex_file.write(tex_fmt % list_to_table(elts))
tex_file.close()
subprocess.check_call(['pdflatex',tex_filename],cwd=tex_dir)
示例4: decodeFile
def decodeFile(self, fn=None):
if not fn:
fn = unicode(QtGui.QFileDialog.getOpenFileName(
self,
u'Open QRCode',
filter=u'Images (*.png *.jpg);; All Files (*.*)'
)
)
if os.path.isfile(fn):
qr = QR(filename=fn)
if qr.decode():
self.showInfo(qr)
else:
QtGui.QMessageBox.information(
self,
u'Decode File',
u'No QRCode could be found in file: <b>%s</b>.' % fn
)
else:
QtGui.QMessageBox.information(
self,
u"Decode from file",
u"The file <b>%s</b> doesn't exist." %
os.path.abspath(fn),
QtGui.QMessageBox.Ok
)
示例5: qrencode
def qrencode(self, fileName=None):
#Functions to get the correct data
data_fields = {
"text": unicode(self.textEdit.toPlainText()),
"url": unicode(self.urlEdit.text()),
"bookmark": ( unicode(self.bookmarkTitleEdit.text()), unicode(self.bookmarkUrlEdit.text()) ),
"email": unicode(self.emailEdit.text()),
"emailmessage": ( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ),
"telephone": unicode(self.telephoneEdit.text()),
"phonebook": (('N',unicode(self.phonebookNameEdit.text())),
('TEL', unicode(self.phonebookTelEdit.text())),
('EMAIL',unicode(self.phonebookEMailEdit.text())),
('NOTE', unicode(self.phonebookNoteEdit.text())),
('BDAY', unicode(self.phonebookBirthdayEdit.date().toString("yyyyMMdd")) if self.phonebookBirthdayLabel.isChecked() else ""), #YYYYMMDD
('ADR', unicode(self.phonebookAddressEdit.text())), #The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order.
('URL', unicode(self.phonebookUrlEdit.text())),
# ('NICKNAME', ''),
),
"sms": ( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ),
"mms": ( unicode(self.mmsNumberEdit.text()), unicode(self.mmsBodyEdit.toPlainText()) ),
"geo": ( unicode(self.geoLatEdit.text()), unicode(self.geoLongEdit.text()) ),
"wifi": ( unicode(self.wifiSSIDEdit.text()), (u"WEP",u"WPA",u"nopass")[self.wifiEncriptionType.currentIndex()], unicode(self.wifiPasswordEdit.text()))
}
data_type = unicode(self.templates[unicode(self.selector.currentText())])
data = data_fields[data_type]
level = (u'L',u'M',u'Q',u'H')
if data:
if data_type == 'emailmessage' and data[1] == '' and data[2] == '':
data_type = 'email'
data = data_fields[data_type]
qr = QR(pixel_size = unicode(self.pixelSize.value()),
data = data,
level = unicode(level[self.ecLevel.currentIndex()]),
margin_size = unicode(self.marginSize.value()),
data_type = data_type,
)
error = 1
if type(fileName) is not unicode:
error = qr.encode()
else:
error = qr.encode(fileName)
if error == 0:
self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
self.saveButton.setEnabled(True)
else:
if NOTIFY:
n = pynotify.Notification(
"QtQR",
unicode(self.trUtf8("ERROR: Something went wrong while trying to generate the QR Code.")),
"qtqr"
)
n.show()
else:
print "Something went wrong while trying to generate the QR Code"
qr.destroy()
else:
self.saveButton.setEnabled(False)
示例6: read
def read(self):
myCode = QR()
print(myCode.decode_webcam())
#print(myCode.data)
#print(myCode.data_type)
#print(myCode.data_to_string())
return myCode.data_to_string
示例7: decodeKey
def decodeKey(file):
decCode = QR(filename=file)
if decCode.decode():
key = decCode.data
int_key = []
for b in key.split('/'):
int_key.append(int(b))
return int_key
示例8: get
def get(self, path):
home_url = options.home_url
if home_url.startswith("http://"):
home_url = home_url[7:]
q=QR(u""+home_url+"/auth/"+path)
q.encode()
self.set_header("Content-Type", "image/gif")
self.write(open(q.filename).read())
示例9: decode_image
def decode_image(filename="default.png"):
"""default.png is a sample image. for more qr code images, see http://qrcode.kaywa.com/"""
my_code = QR(filename=os.path.dirname(os.path.abspath(__file__)) + "/" + filename)
if my_code.decode():
print my_code.data
return my_code.data
else:
return None
示例10: decodeQRCode
def decodeQRCode(fileName, path=""):
"""expects fileName is .jpg"""
myCode = QR(filename = path + fileName)
if myCode.decode():
print "decoderen qr gelukt"
return myCode.data
else:
print "decoderen qr gefaald"
return False
示例11: __init__
def __init__(
self, data=u'NULL', pixel_size=3, level='L', margin_size=4, data_type=u'text', filename=None
):
from qrtools import QR
myCode = QR(data=u"Simpledata", pixel_size=10)
myCode.encode()
print myCode.filename
print myCode
示例12: decodeAES
def decodeAES(key, file):
if isinstance(key, str):
int_key = hexToKey(key)
elif isinstance(key, list):
int_key = key[:]
AESqr = QR(filename=file)
if AESqr.decode():
plaintext = dAES.decrypt(AESqr.data, int_key)
return plaintext
示例13: get_qr_code
def get_qr_code(image_filename):
""" Return True if the given image is a front page (based on a QR code)
or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate
that the page is a front page. """
scanner = QR(filename=image_filename)
if scanner.decode():
data = scanner.data
return data
else:
return None
示例14: readtextfromQR
def readtextfromQR():
try :
from qrtools import QR
from codecs import BOM_UTF8
except ImportError :
print('Module qrtools missing! No QR-code import possible!')
raise
myCode = QR()
myCode.decode_webcam()
key = myCode.data_to_string().strip()
return key[len(BOM_UTF8):] # fixes zbar!
示例15: readQR
def readQR():
future = time.time() + 10
ret = "NULL"
while time.time() < future and ret == "NULL":
myCode = QR()
myCode.decode_webcam()
ret = myCode.data
if ret == "NULL":
return -1
return ret