diff options
author | Joris | 2020-06-07 13:23:13 +0200 |
---|---|---|
committer | Joris | 2020-06-07 13:23:13 +0200 |
commit | df64f28761185bb0a78ecac30ba13378219fd70a (patch) | |
tree | 4f4985c7cdd14caf1cfdb51da2bbe296ac78543c | |
parent | d45a2e5cfe945519e3c8e3f72b92d5c13b4364f5 (diff) |
Augment width of task form dialog
-rw-r--r-- | todo/gui/tasks/dialog.py | 2 | ||||
-rw-r--r-- | todo/gui/tasks/form/widget.py | 28 |
2 files changed, 26 insertions, 4 deletions
diff --git a/todo/gui/tasks/dialog.py b/todo/gui/tasks/dialog.py index 3d9e3c0..c9e3734 100644 --- a/todo/gui/tasks/dialog.py +++ b/todo/gui/tasks/dialog.py @@ -45,7 +45,7 @@ def widget( dialog = QtWidgets.QDialog(parent) dialog.setWindowTitle(title) - dialog.setMinimumSize(QtCore.QSize(320, 240)) + dialog.setMinimumSize(QtCore.QSize(600, 240)) layout = QtWidgets.QVBoxLayout(dialog) dialog.setLayout(layout) diff --git a/todo/gui/tasks/form/widget.py b/todo/gui/tasks/form/widget.py index e547d55..5950a93 100644 --- a/todo/gui/tasks/form/widget.py +++ b/todo/gui/tasks/form/widget.py @@ -33,14 +33,14 @@ def widget( layout = QtWidgets.QVBoxLayout(widget) widget.setLayout(layout) + init_name = task.name if task is not None else "" + name_input = name_edit(widget, layout, "Name", init_name) + grid = QtWidgets.QWidget(widget) layout.addWidget(grid) grid_layout = QtWidgets.QGridLayout(grid) grid.setLayout(grid_layout) - init_name = task.name if task is not None else "" - name_input = line_edit(grid, grid_layout, 0, "Name", init_name) - init_duration = todo.gui.tasks.duration.format(task.duration) if task is not None else "" duration_input = line_edit(grid, grid_layout, 1, "Duration", init_duration) @@ -97,6 +97,28 @@ def widget( return widget +def name_edit( + parent, + layout: QtWidgets.QVBoxLayout, + label: str, + default_value: str) -> QtWidgets.QLineEdit: + + widget = QtWidgets.QWidget(parent) + layout.addWidget(widget) + + inner_layout = QtWidgets.QVBoxLayout(widget) + widget.setLayout(layout) + + label = QtWidgets.QLabel(label, parent) + inner_layout.addWidget(label) + + edit = QtWidgets.QLineEdit(parent) + if default_value != None: + edit.setText(default_value) + inner_layout.addWidget(edit) + + return edit + def line_edit( parent, layout: QtWidgets.QGridLayout, |