aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/tasks/form/widget.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/gui/tasks/form/widget.py b/src/gui/tasks/form/widget.py
index 6421747..64f785a 100644
--- a/src/gui/tasks/form/widget.py
+++ b/src/gui/tasks/form/widget.py
@@ -19,17 +19,19 @@ def widget(
layout = QtWidgets.QVBoxLayout(widget)
widget.setLayout(layout)
+ 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_labelled_input, name_input) = labelled_input(widget, 'Name', init_name)
- layout.addWidget(name_labelled_input)
+ name_input = add_input(grid, grid_layout, 0, 'Name', init_name)
init_duration = gui.tasks.duration.format(task.duration) if task is not None else ''
- (duration_labelled_input, duration_input) = labelled_input(widget, 'Duration', init_duration)
- layout.addWidget(duration_labelled_input)
+ duration_input = add_input(grid, grid_layout, 1, 'Duration', init_duration)
init_tag = task.tag if task is not None else ''
- (tag_labelled_input, tag_input) = labelled_input(widget, 'Tag', init_tag)
- layout.addWidget(tag_labelled_input)
+ tag_input = add_input(grid, grid_layout, 2, 'Tag', init_tag)
task_form_edition = gui.tasks.form.state.TaskFormEdition(
init_name,
@@ -40,29 +42,30 @@ def widget(
tag_input.textChanged)
layout.addWidget(buttons(
- parent = widget,
- action_title = action_title,
- task_form_signal = task_form_edition.signal(),
- on_validate = lambda: validate(task_form_edition.get(), on_validated),
- on_cancel = on_cancel))
+ parent = widget,
+ action_title = action_title,
+ task_form_signal = task_form_edition.signal(),
+ on_validate = lambda: validate(task_form_edition.get(), on_validated),
+ on_cancel = on_cancel))
return widget
-def labelled_input(parent, label: str, default_value: str):
- widget = QtWidgets.QWidget(parent)
-
- layout = QtWidgets.QHBoxLayout(widget)
- widget.setLayout(layout)
+def add_input(
+ parent,
+ layout: QtWidgets.QGridLayout,
+ n: int,
+ label: str,
+ default_value: str) -> QtWidgets.QLineEdit:
- label = QtWidgets.QLabel(label, widget)
- layout.addWidget(label)
+ label = QtWidgets.QLabel(label, parent)
+ layout.addWidget(label, n, 0)
- line_edit = QtWidgets.QLineEdit(widget)
+ line_edit = QtWidgets.QLineEdit(parent)
if default_value != None:
line_edit.setText(default_value)
- layout.addWidget(line_edit)
+ layout.addWidget(line_edit, n, 1)
- return (widget, line_edit)
+ return line_edit
def buttons(parent, action_title, task_form_signal, on_validate, on_cancel):
widget = QtWidgets.QWidget(parent)