-
Notifications
You must be signed in to change notification settings - Fork 0
/
To-Do list app.py
39 lines (28 loc) · 1.12 KB
/
To-Do list app.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
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QPushButton, QListWidget
class ToDoApp(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("To-Do List App")
self.setGeometry(100, 100, 400, 300)
self.tasks = []
self.layout = QVBoxLayout()
self.input_field = QLineEdit()
self.add_button = QPushButton("Add Task")
self.task_list = QListWidget()
self.layout.addWidget(self.input_field)
self.layout.addWidget(self.add_button)
self.layout.addWidget(self.task_list)
self.add_button.clicked.connect(self.add_task)
self.setLayout(self.layout)
def add_task(self):
task = self.input_field.text()
if task:
self.tasks.append(task)
self.task_list.addItem(task)
self.input_field.clear()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = ToDoApp()
window.show()
sys.exit(app.exec_())