(self)
| 66 | QTimer.singleShot(100, self.closeAnimation) # 启动弹回动画 |
| 67 | |
| 68 | def _init(self): |
| 69 | # 隐藏任务栏|去掉边框|顶层显示 |
| 70 | self.setWindowFlags(Qt.Tool | Qt.X11BypassWindowManagerHint | |
| 71 | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) |
| 72 | # 关闭按钮事件 |
| 73 | self.buttonClose.clicked.connect(self.onClose) |
| 74 | # 点击查看按钮 |
| 75 | self.buttonView.clicked.connect(self.onView) |
| 76 | # 是否在显示标志 |
| 77 | self.isShow = True |
| 78 | # 超时 |
| 79 | self._timeouted = False |
| 80 | # 桌面 |
| 81 | self._desktop = QApplication.instance().desktop() |
| 82 | # 窗口初始开始位置 |
| 83 | self._startPos = QPoint( |
| 84 | self._desktop.screenGeometry().width() - self.width() - 5, |
| 85 | self._desktop.screenGeometry().height() |
| 86 | ) |
| 87 | # 窗口弹出结束位置 |
| 88 | self._endPos = QPoint( |
| 89 | self._desktop.screenGeometry().width() - self.width() - 5, |
| 90 | self._desktop.availableGeometry().height() - self.height() - 5 |
| 91 | ) |
| 92 | # 初始化位置到右下角 |
| 93 | self.move(self._startPos) |
| 94 | |
| 95 | # 动画 |
| 96 | self.animation = QPropertyAnimation(self, b"pos") |
| 97 | self.animation.finished.connect(self.onAnimationEnd) |
| 98 | self.animation.setDuration(1000) # 1s |
| 99 | |
| 100 | # 弹回定时器 |
| 101 | self._timer = QTimer(self, timeout=self.closeAnimation) |
| 102 | |
| 103 | def show(self, title="", content="", timeout=5000): |
| 104 | self._timer.stop() # 停止定时器,防止第二个弹出窗弹出时之前的定时器出问题 |
no test coverage detected