1 import sys
2 from PyQt4 import QtGui,QtCore
3
4 class Time(QtGui.QLCDNumber):
5 def __init__(self,parent=None):
6 QtGui.QLCDNumber.__init__(self,parent)
7 #self.setFixedSize(200,200)
8 self.setSegmentStyle(QtGui.QLCDNumber.Filled)
9 timer = QtCore.QTimer(self)
10 timer.timeout.connect(self.show_time)
11 timer.start(1000)
12 self.show_time()
13 self.setWindowTitle('clock')
14 self.resize(100,100)
15 def show_time(self):
16 time = QtCore.QTime.currentTime()
17 #print str(time.hour())+':'+str(time.minute())+':'+str(time.second())
18 text = time.toString('hh:mm')
19 #print text
20 if time.second() % 2 == 0:
21 text = text[:2]+' '+text[3:]
22 self.display(text)
23
24 if __name__=="__main__":
25 app = QtGui.QApplication(sys.argv)
26 time = Time()
27 time.show()
28 sys.exit(app.exec_())

QLCDNumber.display (self, QString str) //


 posted on 2011-07-06 14:05  eth0  阅读(167)  评论(0编辑  收藏  举报