40 lines
1.2 KiB
Python
40 lines
1.2 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)
|
||
|
|
||
|
cancel_button = QtWidgets.QPushButton()
|
||
|
cancel_button.setText("OK")
|
||
|
cancel_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok-apply"))
|
||
|
cancel_button.pressed.connect(self.accept)
|
||
|
|
||
|
ok_button = QtWidgets.QPushButton()
|
||
|
ok_button.setText("Cancel")
|
||
|
ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-cancel"))
|
||
|
ok_button.pressed.connect(self.reject)
|
||
|
|
||
|
blayout = QtWidgets.QHBoxLayout()
|
||
|
blayout.addSpacing(300)
|
||
|
blayout.addWidget(ok_button)
|
||
|
blayout.addWidget(cancel_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()
|