|
[php]
#!/usr/bin/python
#Filename:hello5.py
import sys,random
from PyQt4 import QtCore,QtGui
class Main(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setWindowTitle("Hello Clock!")
self.resize(320,240)
timer = QtCore.QTimer(self)
self.connect(timer, QtCore.SIGNAL("timeout()"), self, QtCore.SLOT("update()"))
timer.start(250)
def paintEvent(self,event):
delta = QtGui.QPolygon([
QtCore.QPoint(-125,0),
QtCore.QPoint(125,0),
QtCore.QPoint(0,125)
])
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
color = QtGui.QColor(r, g, b)
painter = QtGui.QPainter(self)
painter.translate(self.width()/2,0)
painter.setBrush(color)
painter.drawConvexPolygon(delta)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
run = Main()
run.show()
app.exec_()
[/php] |
|