forked from saschaludwig/OnAirScreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclockwidget.py
568 lines (475 loc) · 22.9 KB
/
clockwidget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#############################################################################
#
# OnAirScreen Analog / Digital Clock implementation
# Copyright (c) 2012-2020 Sascha Ludwig, astrastudio.de
# All rights reserved.
#
# start.py
# This file is part of OnAirScreen
#
# You may use this file under the terms of the BSD license as follows:
#
# "Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
#
# this file contains code from Riverbank Computing Limited
# and Nokia Corporation for details: see copyright notice below
#
#############################################################################
#
# Copyright (C) 2010 Riverbank Computing Limited.
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
#
# This file is part of the examples of PyQt.
#
# $QT_BEGIN_LICENSE:BSD$
# You may use this file under the terms of the BSD license as follows:
#
# "Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
# $QT_END_LICENSE$
#
#############################################################################
import time as pytime
from PyQt5 import QtCore, QtGui, QtWidgets
class ClockWidget(QtWidgets.QWidget):
__pyqtSignals__ = ("timeChanged(QTime)", "timeZoneChanged(int)")
# default color scheme
# digiHourColor = QtGui.QColor(255, 0, 0, 255)
# digiSecondColor = QtGui.QColor(255, 0, 0, 255)
def __init__(self, parent=None):
super(ClockWidget, self).__init__(parent)
# astrastudio color scheme
self.digiHourColor = QtGui.QColor(50, 50, 255, 255)
self.digiSecondColor = QtGui.QColor(255, 153, 0, 255)
self.digiDigitColor = QtGui.QColor(50, 50, 255, 255)
# analog mode colors
self.hourColor = QtGui.QColor(200, 200, 200, 255)
self.minuteColor = QtGui.QColor(220, 220, 220, 255)
self.circleColor = QtGui.QColor(220, 220, 220, 255)
self.imagepath = ""
self.setLogo()
self.timeZoneOffset = 0
self.clockMode = 1
self.isAmPm = False
self.showSeconds = False
self.staticColon = False
self.counter = 0
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.update)
self.resyncTime()
def resyncTime(self):
# sync local timer with system clock
while QtCore.QTime.currentTime().msec() > 5:
pytime.sleep(0.001)
self.timer.start(500)
def updateTime(self):
self.timeChanged.emit(QtCore.QTime.currentTime())
@QtCore.pyqtSlot(int)
def getTimeZone(self):
return self.timeZoneOffset
def setTimeZone(self, value):
if value != self.timeZoneOffset:
self.timeZoneOffset = value
self.timeZoneChanged.emit(value)
self.update()
def resetTimeZone(self):
if self.timeZoneOffset != 0:
self.timeZoneOffset = 0
self.timeZoneChanged.emit(0)
self.update()
timeZone = QtCore.pyqtProperty("int", getTimeZone, setTimeZone, resetTimeZone)
@QtCore.pyqtSlot(int)
def setClockMode(self, mode):
if mode == 1:
self.clockMode = 1
else:
self.clockMode = 0
def resetClockMode(self):
self.clockMode = 1
def getClockMode(self):
return self.clockMode
clockType = QtCore.pyqtProperty("int", getClockMode, setClockMode, resetClockMode)
@QtCore.pyqtSlot(bool)
def setAmPm(self, mode):
self.isAmPm = mode
def resetAmPm(self):
self.isAmPm = False
def getAmPm(self):
return self.isAmPm
clockAmPm = QtCore.pyqtProperty("int", getAmPm, setAmPm, resetAmPm)
@QtCore.pyqtSlot(bool)
def setShowSeconds(self, value):
self.showSeconds = value
def resetShowSeconds(self):
self.showSeconds = False
def getShowSeconds(self):
return self.showSeconds
clockShowSeconds = QtCore.pyqtProperty("int", getShowSeconds, setShowSeconds, resetShowSeconds)
@QtCore.pyqtSlot(bool)
def setStaticColon(self, value):
self.staticColon = value
def resetStaticColon(self):
self.staticColon = False
def getStaticColon(self):
return self.staticColon
clockStaticColon = QtCore.pyqtProperty("int", getStaticColon, setStaticColon, resetStaticColon)
@QtCore.pyqtSlot(QtGui.QColor)
def setDigiHourColor(self, color=QtGui.QColor(50, 50, 255, 255)):
self.digiHourColor = color
def resetDigiHourColor(self):
self.digiHourColor = QtGui.QColor(50, 50, 255, 255)
def getDigiHourColor(self):
return self.digiHourColor
colorDigiHour = QtCore.pyqtProperty(QtGui.QColor, getDigiHourColor, setDigiHourColor, resetDigiHourColor)
@QtCore.pyqtSlot(QtGui.QColor)
def setDigiSecondColor(self, color=QtGui.QColor(50, 50, 255, 255)):
self.digiSecondColor = color
def resetDigiSecondColor(self):
self.digiSecondColor = QtGui.QColor(50, 50, 255, 255)
def getDigiSecondColor(self):
return self.digiSecondColor
colorDigiSecond = QtCore.pyqtProperty(QtGui.QColor, getDigiSecondColor, setDigiSecondColor, resetDigiSecondColor)
@QtCore.pyqtSlot(QtGui.QColor)
def setDigiDigitColor(self, color=QtGui.QColor(50, 50, 255, 255)):
self.digiDigitColor = color
def resetDigiDigitColor(self):
self.digiDigitColor = QtGui.QColor(50, 50, 255, 255)
def getDigiDigitColor(self):
return self.digiDigitColor
colorDigiDigit = QtCore.pyqtProperty(QtGui.QColor, getDigiDigitColor, setDigiDigitColor, resetDigiDigitColor)
def paintEvent(self, event):
side = min(self.width(), self.height())
self.time = QtCore.QTime.currentTime()
painter = QtGui.QPainter(self)
painter.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform)
painter.translate(self.width() / 2, self.height() / 2)
painter.scale(side / 200.0, side / 200.0)
if self.clockMode == 0:
self.paintAnalog(painter)
else:
self.paintDigital(painter)
def paintAnalog(self, painter):
time = self.time
# analog clock mode
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(self.hourColor)
# set hour hand length and minute hand length
hhl = -65 # -50
mhl = -85 # -75
shl = -85 # -75
# draw hour hand
painter.save()
painter.rotate(30.0 * (time.hour() + time.minute() / 60.0))
painter.drawRoundedRect(-4, 4, 8, hhl, 4.0, 4.0)
painter.restore()
# draw second hand
painter.save()
painter.rotate(6.0 * time.second())
painter.drawRoundedRect(-1, 1, 2, shl, 1.0, 1.0)
painter.restore()
painter.setPen(self.hourColor)
for i in range(12):
painter.drawRoundedRect(88, -1, 8, 2, 1.0, 1.0)
painter.rotate(30.0)
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(self.minuteColor)
# draw minute hand
sizefactor = 1.3
painter.save()
painter.rotate(6.0 * (time.minute() + time.second() / 60.0))
painter.drawRoundedRect(-4 / sizefactor, 4 / sizefactor, 8 / sizefactor, mhl, 4.0 / sizefactor,
4.0 / sizefactor)
painter.restore()
# draw center circle
painter.setBrush(self.circleColor)
painter.save()
painter.drawEllipse(-6, -6, 12, 12)
painter.restore()
painter.setPen(self.minuteColor)
for j in range(60):
if (j % 5) != 0:
painter.drawLine(92, 0, 96, 0)
painter.rotate(6.0)
# end analog clock mode
@QtCore.pyqtSlot(str)
def setLogo(self, logofile=""):
self.imagepath = logofile
self.image = QtGui.QImage(logofile)
def getLogo(self):
return self.imagepath
def resetLogo(self):
self.setLogo()
logoFile = QtCore.pyqtProperty(str, getLogo, setLogo, resetLogo)
def paintDigital(self, painter):
# digital clock mode
time = self.time
dotSize = 1.6
# draw digits and colon
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(self.digiDigitColor)
painter.setPen(self.digiDigitColor)
digitSpacing = 28
digitSpacingY = 45
secondsOffsetX = -3.5
if self.isAmPm and time.hour() > 12:
if time.hour() >= 12:
hourStr = "%02d" % (time.hour() - 12)
else:
hourStr = "%02d" % time.hour()
else:
hourStr = "%02d" % time.hour()
self.drawDigit(painter, digitSpacing * -2, 0, hourStr[0:1])
self.drawDigit(painter, digitSpacing * -1, 0, hourStr[1:2])
self.drawColon(painter, 0, 0)
minuteStr = "%02d" % time.minute()
self.drawDigit(painter, digitSpacing * 1, 0, minuteStr[0:1])
self.drawDigit(painter, digitSpacing * 2, 0, minuteStr[1:2])
if self.showSeconds:
secondStr = "%02d" % time.second()
self.drawDigit(painter, (digitSpacing * -0.3) + secondsOffsetX, digitSpacingY, secondStr[0:1], 0.8, 3)
self.drawDigit(painter, (digitSpacing * 0.3) + secondsOffsetX, digitSpacingY, secondStr[1:2], 0.8, 3)
# set painter to 12 o'clock position
painter.rotate(-90.0)
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(self.digiHourColor)
painter.setPen(self.digiHourColor)
# draw hour marks
painter.save()
for i in range(12):
painter.drawEllipse(QtCore.QPointF(95, 0), dotSize, dotSize)
painter.rotate(30.0)
painter.restore()
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(self.digiSecondColor)
painter.setPen(self.digiSecondColor)
# draw seconds
painter.save()
# draw zero second
# painter.drawEllipse(QtCore.QPointF(88,0), dotSize, dotSize)
# painter.rotate(6.0)
second = time.second() + 1
if second == 0: second = 60
for j in range(0, second):
painter.drawEllipse(QtCore.QPointF(88, 0), dotSize, dotSize)
painter.rotate(6.0)
painter.restore()
# add logo
image_max_h = 40
image_max_w = 100
image = self.image
image_w = image.width()
image_h = image.height()
if image_w > 0 and image_h > 1:
painter.save()
painter.rotate(90)
if self.showSeconds:
# logo position and width when showing seconds
paint_x = 0
paint_y = -50
else:
# logo position and width without seconds
paint_x = 0
paint_y = 50
if image_w > image_h:
# calculate height from aspect ratio
paint_w = image_max_w
paint_h = (float(image_h) / float(image_w)) * paint_w
else:
# calculate width from aspect ratio
paint_h = image_max_h
paint_w = (float(image_h) / float(image_w)) * paint_h
painter.drawImage(QtCore.QRectF(paint_x - (paint_w / 2), paint_y - (paint_h / 2), paint_w, paint_h), image)
painter.restore()
# end digital clock mode
def drawColon(self, painter, digitStartPosX=0, digitStartPosY=0):
# paint colon only half a second
if self.time.msec() < 500 or self.staticColon:
dotSize = 1.6
dotOffset = 4.5 # spacing between the dots
dotSlant = dotOffset / 15 # horizontal slant of each row
currentRow = +1.5
painter.drawEllipse(
QtCore.QPointF(digitStartPosX + (dotSlant * 2 * currentRow), digitStartPosY - (dotOffset * currentRow)),
dotSize, dotSize)
currentRow = -1.2
painter.drawEllipse(
QtCore.QPointF(digitStartPosX + (dotSlant * 2 * currentRow), digitStartPosY - (dotOffset * currentRow)),
dotSize, dotSize)
def drawDigit(self, painter, digitStartPosX=0.0, digitStartPosY=0.0, value=8, dotSize=1.6, dotOffset=4.5, slant=19):
value = int(value)
# draw dots from one 7segment digit
dotSlant = dotOffset / slant # horizontal slant of each row
# decimal to segment conversion table
segments = [0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111,
0b1101111]
if segments[value] & 1 << 6:
# segment g
currentRow = 0 # center row
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 0:
# segment a
currentRow = 9 # top row
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 3:
# segment d
currentRow = -9 # bottom row
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX - (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 0.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
painter.drawEllipse(QtCore.QPointF(digitStartPosX + (dotOffset * 1.5) + (dotSlant * currentRow),
digitStartPosY - (dotOffset / 2 * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 5:
# segment f
yOffset = -0.75
xOffset = +0.75
currentRow = 1
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 2
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 3
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 4
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 1:
# segment b
yOffset = -1.2
xOffset = -0.5
currentRow = 1
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 2
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 3
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = 4
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 4:
# segment e
yOffset = +1.2
xOffset = +0.5
currentRow = -1
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -2
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -3
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -4
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset - (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
if segments[value] & 1 << 2:
# segment c
yOffset = +0.75
xOffset = -0.75
currentRow = -1
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -2
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -3
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
currentRow = -4
painter.drawEllipse(
QtCore.QPointF(digitStartPosX - xOffset + (dotOffset * 2.0) + (dotSlant * 2 * currentRow),
digitStartPosY - yOffset - (dotOffset * currentRow)), dotSize, dotSize)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
widget = ClockWidget()
widget.setStyleSheet("background-color:black;")
widget.resize(500, 500)
widget.setClockMode(1)
widget.setAmPm(False)
widget.setShowSeconds(True)
widget.setStaticColon(False)
widget.show()
sys.exit(app.exec_())