summaryrefslogtreecommitdiffstats
path: root/examples/dclock.py
diff options
context:
space:
mode:
authoraneejit1 <aneejit1@gmail.com>2022-07-28 15:46:19 +0000
committerSlávek Banko <slavek.banko@axis.cz>2022-07-31 16:41:03 +0200
commit4978511ebb7e8d31dab64485d1ac87b6e004be81 (patch)
treea2da3161f070116baa15de7276c5c0c9ac855e8f /examples/dclock.py
parent5916692cf4c4df4f808e346c9bda1604960a0ff3 (diff)
downloadpytqt-4978511ebb7e8d31dab64485d1ac87b6e004be81.tar.gz
pytqt-4978511ebb7e8d31dab64485d1ac87b6e004be81.zip
Remove Qt V2 support and example files
Build files for pyuic2 have been removed along with the examples for version 2 of Qt and the build/configure scripts have been amended accordingly. The "examples3" directory has been renamed to just "examples". Signed-off-by: aneejit1 <aneejit1@gmail.com> (cherry picked from commit e602246539fd7435aaeb440fcb7f852c92c8426b)
Diffstat (limited to 'examples/dclock.py')
-rwxr-xr-xexamples/dclock.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/dclock.py b/examples/dclock.py
new file mode 100755
index 0000000..302d454
--- /dev/null
+++ b/examples/dclock.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+# A port to PyTQt of the dclock example from TQt v2.x.
+
+
+import sys, string
+from python_tqt.qt import *
+
+
+class DigitalClock(TQLCDNumber):
+ def __init__(self, parent=None, name=None):
+ TQLCDNumber.__init__(self, parent, name)
+ self.showingColon = 0
+ self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
+ self.setLineWidth(2)
+ self.showTime()
+ self.normalTimer = self.startTimer(500)
+ self.showDateTimer = -1
+
+ def timerEvent(self, e):
+ if e.timerId() == self.showDateTimer:
+ self.stopDate()
+ else:
+ if self.showDateTimer == -1:
+ self.showTime()
+
+ def mousePressEvent(self, e):
+ if e.button() == TQt.LeftButton:
+ self.showDate()
+
+ def showDate(self):
+ if self.showDateTimer != -1:
+ return
+ d = TQDate.currentDate()
+ self.display('%2d %2d' % (d.month(), d.day()))
+ self.showDateTimer = self.startTimer(2000)
+
+ def stopDate(self):
+ self.killTimer(self.showDateTimer)
+ self.showDateTimer = -1
+ self.showTime()
+
+ def showTime(self):
+ self.showingColon = not self.showingColon
+ s = list(str(TQTime.currentTime().toString())[:5]) #.left(5)
+ if not self.showingColon:
+ s[2] = ' '
+ if s[0] == '0':
+ s[0] = ' '
+ s = ''.join(s)
+ self.display(s)
+
+a = TQApplication(sys.argv)
+clock = DigitalClock()
+clock.resize(170,80)
+a.setMainWidget(clock)
+clock.show()
+a.exec_loop()