用Python + PyQT写的一个系统桌面时钟,刚学习Python,写的比较简陋,但是基本的功能还可以。
功能:
①窗体在应用程序最上层,不用但是打开其他应用后看不到时间
②左键双击全屏,可以做小屏保使用,再次双击退出全屏。
③系统托盘图标,主要参考PyQt4源码目录中的PyQt4\examples\desktop\systray下的程序
④鼠标右键,将程序最小化
使用时需要heart.svg放在源代码同级目录下,[文件可在PyQt4示例代码目录下PyQt4\examples\desktop\systray\images找到
运行需要Python2.7 + PyQt4.
__metaclass__ = type
#!coding= utf-8
#http://blog.csdn.net/gatieme/article/details/17659259
#gatieme
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#--------------------------------------------------------------------------------
class SystemTrayIcon(QSystemTrayIcon):
"""
The systemTrayIcon which uesd to connect the clock
"""
#----------------------------------------------------------------------------
def __init__(self, mainWindow, parent = None):
"""
mainWindow : the main window that the system tray icon serves to
"""
super(SystemTrayIcon, self).__init__(parent)
self.window = mainWindow
self.setIcon(QIcon("heart.svg")) # set the icon o