import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt
from PyQt4.QtCore import QPoint
from PyQt4.QtCore import QTimer
from PyQt4.QtCore import QTime
from PyQt4.QtGui import QPainter
from PyQt4.QtGui import QColor
from PyQt4.QtGui import QPolygon
from PyQt4.QtCore import SIGNAL as signal
class Clock(QtGui.QWidget):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
super(Clock, self).__init__()
self.hourColor=QColor(127, 0, 127);
self.minuteColor=QColor(0, 127, 127, 191)
self.secondColor=QColor(127, 127,0,120)
self.initUI()
self.timer = QTimer()
self.timer.timeout.connect(self.update)
self.timer.start(30)
self.show()
def handChange(self):
self.side = min(self.width(), self.height())
self.hand=(max(self.side/200,4), max(self.side/100,8), max(self.side/40,30))
self.hourHand=QPolygon([QPoint(self.hand[0],self.hand[1]),QPoint(-self.hand[0],self.hand[1]),QPoint(0,-self.hand[2])])
self.minuteHand=QPolygon([QPoint(self.hand[0],self.hand[1]),QPoint(-self.hand[0],self.hand[1]),QPoint(0,-self.hand[2]*2)])
self.secondHand=QPolygon([QPoint(self.hand[0],self.hand[1]),QPoint(-self.hand[0],self.hand[1]),QPoint(0,-self.hand[2]*3)])
<