1 Star 6 Fork 5

墨梅/createCard

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.py 4.18 KB
一键复制 编辑 原始数据 按行查看 历史
墨梅 提交于 2020-05-16 14:17 . 将图片打包进exe
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
from PyQt5.QtGui import *
import webbrowser
import MainWindow as window
import WriteImg
import RandomFun as common
import PrepareData
def open_blog():
webbrowser.open("https://blog.csdn.net/GISuuser")
def init_listener(ui, MainWindow):
"""初始化各类点击事件"""
ui.action_4.triggered.connect(open_blog)
ui.action_5.triggered.connect(lambda: show_qq(MainWindow))
ui.action_6.triggered.connect(lambda: show_license(MainWindow))
ui.action_3.triggered.connect(lambda: random_bank(ui))
ui.action.triggered.connect(lambda: random_phone(ui))
ui.action_2.triggered.connect(lambda: random_id_card(ui))
ui.action_1.triggered.connect(lambda: random_license(ui))
def random_license(ui):
"""随机营业执照"""
clear_content(ui)
code = common.create_social_credit()
img = WriteImg.writeImgLicense("data/license.png", code, x=220, y=220, tx=600, ty=426)
height, width, channel = img.shape
bytesPerline = 3 * width
qImg = QImage(img.data, width, height, bytesPerline, QImage.Format_RGB888).rgbSwapped()
jpg = QPixmap.fromImage(qImg).scaled(600, 426)
ui.label.setFixedSize(600, 426)
ui.label.setScaledContents(True)
ui.label.setPixmap(jpg)
ui.plainTextEdit.setPlainText(code)
def show_qq(parent):
"""展示联系方式"""
QMessageBox.about(parent, '联系方式', 'QQ:965894265')
def show_license(parent):
"""展示联系方式"""
QMessageBox.about(parent, '使用协议', '不许商用!不允许用于非法活动')
def clear_content(ui):
"""清空内容"""
ui.label.setPixmap(QPixmap(""))
ui.label_2.setPixmap(QPixmap(""))
ui.plainTextEdit.setPlainText("")
def random_phone(ui):
"""随机手机号"""
clear_content(ui)
ui.plainTextEdit.setPlainText(common.random_phone())
def random_bank(ui):
"""随机银行卡"""
clear_content(ui)
bank_info = common.create_bank_account()
img = WriteImg.writeImgBank("data/bank2.png", bank_info["number"], x=80, y=240, tx=600, ty=382)
img = WriteImg.paint_chinese(img, bank_info["bank"], pos=(440, 310),color=(0,0,255))
height, width, channel = img.shape
bytesPerline = 3 * width
qImg = QImage(img.data, width, height, bytesPerline, QImage.Format_RGB888).rgbSwapped()
jpg = QPixmap.fromImage(qImg).scaled(600, 382)
ui.label.setFixedSize(600, 382)
ui.label.setScaledContents(True)
ui.label.setPixmap(jpg)
ui.plainTextEdit.setPlainText(bank_info["bank"] + bank_info["number"])
def random_id_card(ui):
"""随机银行卡"""
clear_content(ui)
person_info=common.random_name()
id_number=common.create_idcard()
ui.plainTextEdit.setPlainText(person_info["name"])
sex=""
if person_info["sex"]:
sex = "男"
ui.plainTextEdit.appendPlainText("男")
else:
sex = "女"
ui.plainTextEdit.appendPlainText("女")
ui.plainTextEdit.appendPlainText(id_number)
# 展示身份证正面
img = WriteImg.writeImgId("data/id_front.png", id_number, x=900, y=1500)
img = WriteImg.paint_chinese_id(img, person_info["name"], pos=(500, 230))
img = WriteImg.paint_chinese_id(img, sex, pos=(500, 430))
height, width, channel = img.shape
bytesPerline = 3 * width
qImg = QImage(img.data, width, height, bytesPerline, QImage.Format_RGB888).rgbSwapped()
jpg = QPixmap.fromImage(qImg)
ui.label.setFixedSize(600, 385)
ui.label.setScaledContents(True)
ui.label.setPixmap(jpg)
# 展示身份证背面
img = WriteImg.get_img("data/id_back.png")
height, width, channel = img.shape
bytesPerline = 3 * width
qImg = QImage(img.data, width, height, bytesPerline, QImage.Format_RGB888).rgbSwapped()
jpg = QPixmap.fromImage(qImg)
ui.label_2.setFixedSize(600, 385)
ui.label_2.setScaledContents(True)
ui.label_2.setPixmap(jpg)
def prepare_data():
"""程序第一次运行加载图片"""
PrepareData.prepare_data()
if __name__ == '__main__':
prepare_data()
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = window.Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
init_listener(ui, MainWindow)
sys.exit(app.exec_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/GISuser/createCard.git
git@gitee.com:GISuser/createCard.git
GISuser
createCard
createCard
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385