-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskViewer.py
More file actions
80 lines (58 loc) · 2.37 KB
/
TaskViewer.py
File metadata and controls
80 lines (58 loc) · 2.37 KB
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
from CustomControl import Label, LCDNumber
from PyQt5.QtGui import QStandardItemModel
from PyQt5.QtWidgets import QApplication, QGridLayout, QTableView, QWidget
class TaskViewer(QWidget):
'''Widget which diplays a countdown to the next deadline and the upcoming
tasks.'''
def __init__(self, parent=None):
super(TaskViewer, self).__init__(parent)
layout = QGridLayout()
layout.addWidget(self.createCountDown(), 0, 0)
layout.addWidget(self.createUpcomingTasks(), 1, 0)
self.setLayout(layout)
def displayCountDown(self, hour, minute):
'''Display the hour and minute on the LCD displays. The hour and minute
have two digits each. Extra digits are filled with zeros.'''
hour = max(hour, 0)
minute = max(minute, 0)
self.countDownHour.display('{:02d}'.format(hour))
self.countDownMinute.display('{:02d}'.format(minute))
def createCountDown(self):
'''Create and return a widget containing a countdown to the next
deadline.'''
layout = QGridLayout()
layout.addWidget(Label('Next deadline comes in:'), 0, 0, 1, 4)
layout.addWidget(Label('hr'), 1, 1)
layout.addWidget(Label('min'), 1, 3)
self.countDownHour = LCDNumber(2)
layout.addWidget(self.countDownHour, 1, 0)
self.countDownMinute = LCDNumber(2)
layout.addWidget(self.countDownMinute, 1, 2)
widget = QWidget()
widget.setLayout(layout)
return widget
def createUpcomingTasks(self):
'''Create and return a table countaining the basic information of the
upcoming tasks.'''
layout = QGridLayout()
layout.addWidget(Label('Upcoming tasks:'), 0, 0)
model = QStandardItemModel()
model.setHorizontalHeaderLabels(['Name', 'Start', 'End', 'Deadline'])
self.tableView = QTableView()
self.tableView.setModel(model)
layout.addWidget(self.tableView, 1, 0)
self.tableView.setStyleSheet(self.tableView.styleSheet() + '''
QTableView * {
font-family: Verdana, Geneva, sans-serif;
font-size: 10pt;
}
''')
widget = QWidget()
widget.setLayout(layout)
return widget
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
viewer = TaskViewer()
viewer.show()
app.exec_()