From df64f28761185bb0a78ecac30ba13378219fd70a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 7 Jun 2020 13:23:13 +0200 Subject: Augment width of task form dialog --- todo/gui/tasks/dialog.py | 2 +- 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, -- cgit v1.2.3