fime/new_task.py
2021-11-16 23:55:58 +01:00

45 lines
1.4 KiB
Python

from PySide2 import QtGui, QtWidgets
from task_completer import TaskCompleter
class NewTask(QtWidgets.QDialog):
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.setWindowTitle("New Tasks")
self.line_edit = QtWidgets.QLineEdit()
completer = TaskCompleter()
self.line_edit.setCompleter(completer)
self.line_edit.textChanged.connect(completer.update_picker)
ok_button = QtWidgets.QPushButton()
ok_button.setText("OK")
ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok-apply"))
ok_button.pressed.connect(self.accept)
ok_button.setAutoDefault(True)
cancel_button = QtWidgets.QPushButton()
cancel_button.setText("Cancel")
cancel_button.setIcon(QtGui.QIcon.fromTheme("dialog-cancel"))
cancel_button.pressed.connect(self.reject)
cancel_button.setAutoDefault(False)
blayout = QtWidgets.QHBoxLayout()
blayout.addSpacing(300)
blayout.addWidget(cancel_button)
blayout.addWidget(ok_button)
layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.line_edit)
layout.addLayout(blayout)
self.setLayout(layout)
self.resize(500, 0)
@property
def task_text(self):
return self.line_edit.text()
def reset_task_text(self):
self.line_edit.setText("")