在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.FramelessWindowHi

本文介绍了如何在Python的PyQT5环境中创建一个无边框、背景透明的toast气泡窗口。通过设置窗口属性,实现了类似的功能。详细步骤和代码参考链接已给出。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



