清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
class LcdTime(QtGui.QWidget):
def __init__(self, parent=None):
super(LcdTime, self).__init__(parent)
self.hour = QtGui.QLCDNumber(8, self)
self.hour.setGeometry(10, 10, 200, 80)
self.hour.setSegmentStyle(QtGui.QLCDNumber.Flat)
self.display()
self.timer = QtCore.QTimer()
self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.display)
self.timer.start(1000)
self.resize(220, 100)
self.setmetry()
self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
self.tray()
def tray(self):
self.trayIcon = QtGui.QSystemTrayIcon(self)
self.trayIcon.setIcon(QtGui.QIcon('logo.png'))
self.trayIcon.show()
self.trayIcon.setToolTip('时钟 -LiKui')
self.trayIcon.activated.connect(self.trayClick)
menu = QtGui.QMenu()
normalAction = menu.addAction('正常显示')
miniAction = menu.addAction('最小化托盘')
exitAction = menu.addAction('退出')
normalAction.triggered.connect(self.showNormal)
exitAction.triggered.connect(sys.exit)
miniAction.triggered.connect(self.showMinimized)
self.trayIcon.setContextMenu(menu)
def trayClick(self, reason):
if reason == QtGui.QSystemTrayIcon.DoubleClick:
self.showNormal()
def display(self):
current = QtCore.QTime.currentTime()
self.hour.display(current.toString('HH:mm:ss'))
def setmetry(self):
screen = QtGui.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move(screen.width() - size.width(), 0)
app = QtGui.QApplication(sys.argv)
lcd = LcdTime()
lcd.show()
sys.exit(app.exec_())