请帮我写一个pyqt6 windows右下角弹窗的脚本
时间: 2023-06-06 12:08:18 浏览: 149
好的,以下是一个例子,基于PyQt6实现在Windows右下角弹出提示窗口:
```python
from PyQt6.QtWidgets import *
class Notification(QSystemTrayIcon):
def __init__(self, parent=None):
super().__init__(parent)
self.setIcon(self.style().standardIcon(QStyle.SP_MessageBoxInformation))
self.setVisible(True)
def showMessage(self, message):
self.showMessage('Notification', message, QSystemTrayIcon.Information, 5000)
if __name__ == '__main__':
app = QApplication([])
trayIcon = Notification()
trayIcon.showMessage('Hello world!')
app.exec()
```
这段代码会创建一个QSystemTrayIcon,它会在系统托盘中显示一个图标。当你调用showMessage函数并传入提示信息时,它会在屏幕右下角弹出一个窗口,显示相应的消息。
注意:为了让该代码在Windows上正常工作,需要将该代码保存为.pyw文件,以便在没有控制台的情况下以GUI模式运行。
阅读全文
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)