Skip to content

Commit

Permalink
Merge branch 'add_validation_to_create_folders' of https://github.com…
Browse files Browse the repository at this point in the history
…/neuroinformatics-unit/datashuttle into add_validation_to_create_folders
  • Loading branch information
b-peri committed Nov 22, 2023
2 parents 5d9ab54 + fe20d78 commit c8391b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions datashuttle/tui/css/tui_menu.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
align: center top;
margin: 3 2 0 0;
content-align: center middle;
height: auto;
}

#project_select_top_container > Button {
Expand Down
28 changes: 23 additions & 5 deletions datashuttle/tui/custom_widgets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Dict

if TYPE_CHECKING:
from textual import events
Expand Down Expand Up @@ -53,22 +53,40 @@ def compose(self):
value=checkboxes_on[datatype],
)

def on_mount(self):
"""
Update datatype out based on the current checkbox
ticks which are determined during `compose().`
"""
datatype_dict = self.get_datatype_dict()
self.set_datatype_out(datatype_dict)

def on_checkbox_changed(self):
"""
When a checkbox is clicked, update the `datatype_out` attribute
with the datatypes to pass to `make_folders` datatype argument.
"""
datatype_dict = {
datatype: self.query_one(f"#tabscreen_{datatype}_checkbox").value
for datatype in self.datatype_config
}
datatype_dict = self.get_datatype_dict()

# This is slightly wasteful as update entire dict instead
# of changed entry, but is negligible.
self.persistent_settings["tui"]["checkboxes_on"] = datatype_dict

self.project._save_persistent_settings(self.persistent_settings)

self.set_datatype_out(datatype_dict)

def get_datatype_dict(self) -> Dict:
""""""
datatype_dict = {
datatype: self.query_one(f"#tabscreen_{datatype}_checkbox").value
for datatype in self.datatype_config
}

return datatype_dict

def set_datatype_out(self, datatype_dict: dict) -> None:
""""""
self.datatype_out = [
datatype
for datatype, is_on in zip(
Expand Down

0 comments on commit c8391b9

Please sign in to comment.