在Python平台上利用pyqt5实现toast气泡
原理
在python上实现toast实际上就是新建一个无边框(QtCore.Qt.FramelessWindowHint),背景色透明(QtCore.Qt.WA_TranslucentBackground)的新窗口。Talk is cheap,show you the code.废话少说,放码过来。
import sys
import threading
from qtpy import QtWidgets
from qtpy import QtGui
from qtpy import QtCore
class Toast(QtWidgets.QWidget):
background_color = QtGui.QColor("#778899")
text_color = QtCore.Qt.black
font = QtGui.QFont('Simsun', 10)
text = ''
times = 3
parent = None
min_height = 10
min_width = 10
pos = QtCore.QPointF(0, 0)
def __init__(self, parent=None,):
super(Toast, self).__init__(parent)
self.parent = parent
self.setWindowFlags(QtCore.Qt