代码拉取完成,页面将自动刷新
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_())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。