Giter Site home page Giter Site logo

py_qrvcard's Introduction

py_qrvcard

一个采用 PyQt4 和 qrcode 两个库 完成的 python 二维码名片生成小程序。

二维码名片采用 VCARD格式,下面给出一个 VCARD格式例子,

VCARD格式示例

BEGIN:VCARD
VERSION:3.0
N:王辉
ORG:whut
EMAIL;HOME:[email protected]
EMAIL;WORK:[email protected]
TEL;WORK:18200000000
TEL;HOME:0731-24000000
ADR:Hx-xxx
EDN:VCARD

##文件结构 所有的程序文件包含在文件夹 VARD。

test 文件夹,包含了两个测试的demo。

card.pyw python入口程序

card.ui 程序的界面设计文件

card_ui.[py/pyc] 由 card.ui 自动生成的python程序

update_ui.bat 用于重新将 card.ui 编译为 card.py 的批处理命令

logo.png 默认的二维码名片中间logo图标

##一些用法

QLabel:显示图片 card_0.jpg 到self.ui.image

	reader = QtGui.QImageReader( QtCore.QString("card_0.jpg") )
	qimg = reader.read()
	pixmap = QtGui.QPixmap.fromImage(qimg)
	self.ui.image.setPixmap(pixmap)
从文件中读取图片,并绘制在QLabel中

生成二维码并输出为文件:

	qr = qrcode.QRCode(
		version=1,
			   error_correction=qrcode.constants.ERROR_CORRECT_L,
		box_size=10,
		border=4,
	)
	qr.add_data('http://www.baidu.com/')
	qr.make(fit=True)
	img = qr.make_image()
	img_file = open("card1.jpg","wb")
	img.save(img_file,'jpeg')
	img_file.close()

connect用法:

	QtCore.QObject.connect(self.ui.pushButton_make,QtCore.SIGNAL("clicked()"),self.onGenerateQRCode)

读取lineedit控件数据

	qstr_name = self.ui.lineEdit_name.text()
qstr_name 为 QtCore.QString 类型,与str 性质差不多

debug: set param

    self.ui.lineEdit_name.setText( _fromUtf8("王辉") )
    self.ui.lineEdit_mobilephone.setText( _fromUtf8("18200000000") )
    self.ui.lineEdit_email.setText( _fromUtf8("[email protected]") )
    self.ui.lineEdit_address.setText( _fromUtf8("武汉理工大学") )

py_qrvcard's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.