当前位置: 首页>>代码示例>>Python>>正文


Python qrtools.QR类代码示例

本文整理汇总了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)
开发者ID:prashantyahide,项目名称:qtqr,代码行数:25,代码来源:qtqr.py

示例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."
开发者ID:8bitninja3000,项目名称:btcatm,代码行数:25,代码来源:bitcoinc2.py

示例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)
开发者ID:abuchan,项目名称:inventory,代码行数:26,代码来源:qr_generator.py

示例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
         )
开发者ID:prashantyahide,项目名称:qtqr,代码行数:26,代码来源:qtqr.py

示例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)
开发者ID:BenjaminHae,项目名称:qtqr,代码行数:60,代码来源:qtqr.py

示例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
开发者ID:jeryfast,项目名称:piflyer,代码行数:7,代码来源:qr_reader.py

示例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 
开发者ID:rolandshoemaker,项目名称:aesQR,代码行数:8,代码来源:aesQR.py

示例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())
开发者ID:Hackerfarm,项目名称:qrinventory,代码行数:8,代码来源:inv.py

示例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
开发者ID:kai33,项目名称:NaviCane,代码行数:8,代码来源:qrcode_reader.py

示例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
开发者ID:nielsdb,项目名称:zeppelin,代码行数:9,代码来源:camera.py

示例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
开发者ID:zleap,项目名称:python-qrcode,代码行数:9,代码来源:qrgen1.py

示例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
开发者ID:rolandshoemaker,项目名称:aesQR,代码行数:9,代码来源:aesQR.py

示例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
开发者ID:ottobonn,项目名称:exam-normalizer,代码行数:10,代码来源:normalize.py

示例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!
开发者ID:VoR0220,项目名称:bitshares-pytools,代码行数:11,代码来源:tools.py

示例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
开发者ID:acm-uiuc,项目名称:tatt,代码行数:11,代码来源:tattGUI.py


注:本文中的qrtools.QR类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。