没有合适的资源?快使用搜索试试~ 我知道了~
首页python实现桌面气泡提示功能
python实现桌面气泡提示功能
880 浏览量
更新于2023-05-27
评论 1
收藏 176KB PDF 举报
主要为大家详细介绍了python实现桌面气泡提示功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
资源详情
资源评论
资源推荐

python实现桌面气泡提示功能实现桌面气泡提示功能
主要为大家详细介绍了python实现桌面气泡提示功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
在写桌面软件时,通常会使用到托盘上的泡泡提示功能,让我们来看看使用python如何实现这个小功能。
一、一、Linux系统系统
在Linux上,实现一个气泡提示非常简单,使用GTK实现的pynotify模块提供了些功能,我的环境是Ubuntu,默认安装此模块,如果没
有,下载源文件编译安装一个。实现代码如下:
#!/usr/bin/python
#coding:utf-8
import pynotify
pynotify.init ("Bubble@Linux")
bubble_notify = pynotify.Notification ("Linux上的泡泡提示", "看,比Windows上实现方便多了!")
bubble_notify.show ()
效果:
二、二、Windows下的实现下的实现
Windows下实现是比较复杂的,没有pynotify这样一个模块,找到了一个还算不错的模块(地址),这个类有些语法上的小问题,至少在
python2.6下如此,需要修改一下,如下是修改后的代码),基本可用,代码如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#gtkPopupNotify.py
#
# Copyright 2009 Daniel Woodhouse
# modified by NickCis 2010 http://github.com/NickCis/gtkPopupNotify
# Modifications:
# Added: * Corner support (notifications can be displayed in all corners
# * Use of gtk Stock items or pixbuf to render images in notifications
# * Posibility of use fixed height
# * Posibility of use image as background
# * Not displaying over Windows taskbar(taken from emesene gpl v3)
# * y separation.
# * font description options
# * Callbacks For left, middle and right click
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Lesser General Public License as published by











安全验证
文档复制为VIP权益,开通VIP直接复制

评论0