PyQt5 制作验证码
import random
from PyQt5.QtWidgets import QWidget
from PyQt5.QtGui import QPainter, QColor, QFont, QPixmap, QPolygon, QPen
from PyQt5.QtCore import Qt, QRect, QPoint
from utils import runtime_global_storage
class Example(QWidget):
def __init__(self, pic_width, v_code_width, v_code_height, multiple):
'''
:param pic_width: 显示图片的宽度
:param v_code_width: 画布宽度
:param v_code_height: 画布高度
:param multiple: 验证码间隔
'''
super().__init__()
self.initUI()
self.pic_width = pic_width
self.v_code_width = v_code_width
self.v_code_height = v_code_height
self.multiple = multiple
def initUI(self):
self.setGeometry(0, 0, 380, 53)
self.setWindowTitle("Draw text")
self.show()
runtime_global_storage.v_code_class = self
def paintEvent(self, event):
qp = Q