-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPROJECT.py
More file actions
31 lines (27 loc) · 1.09 KB
/
Copy pathPROJECT.py
File metadata and controls
31 lines (27 loc) · 1.09 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
from PyQt5.QtWidgets import QApplication, QMainWindow, QListWidgetItem
from PyQt5.uic import loadUi
import sys
from qtconsole.qt import QtCore
class Main(QMainWindow):
def __init__(self):
super(Main, self).__init__()
loadUi("main.ui", self)
todos = ["Kerjakan Projek", "Kerjakan PR", "Cuci mobil", "Ambil jemuran"]
for todo in todos:
item = QListWidgetItem(todo)
item.setFlags(item.flags() | QtCore.Qt.IterIsUserCHeckable)
item.setCheckState(QtCore.Qt.Unchecked)
self.todo_listWidget.addItem(item)
self.ToggleAllButton.clicked.connect(self.toggle_all)
def toggle_all(self):
for i in range(self.todo_listWidget.count()):
item = self.todo_listWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
item.setCheckState(QtCore.Qt.Checked)
else:
item.setCheckState(QtCore.Qt.Checked)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Main()
window.show()
app.exec_()