Skip to content

Commit

Permalink
resolve commments
Browse files Browse the repository at this point in the history
  • Loading branch information
4rnaudB committed Jan 17, 2024
1 parent 614a3a6 commit 34c2c50
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
8 changes: 0 additions & 8 deletions .vscode/settings.json

This file was deleted.

25 changes: 19 additions & 6 deletions fsleyes_plugin_shimming_toolbox/components/checkbox_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@
class CheckboxComponent(Component):
def __init__(self, panel, label, checkbox_metadata, option_name, components_dict={}, info_text=None, additional_sizer_dict=None):
"""
Create a checkbox object
Args:
list_components (list): list of Components
component_to_dropdown_choice (list): Tells which component associates with which dropdown selection.
If None, assumes 1:1.
panel (wx.Panel): A panel is a window on which controls are placed.
label (str): Label of the button describing the checkbox
checkbox_metadata (list)(dict): A list of dictionaries where the dictionaries have the
required keys: ``label``, ``option_value``.
.. code::
{
"label": The label for the checkbox
"option_value": The value linked to the option in the CLI
}
option_name (str): Name of the options of the checkbox, start with 'no_arg' if it is not an option
components_dict (dict): Dictionary of components to shown when the checkbox is checked
info_text (str): Info message displayed when hovering over the "i" icon. Leave blank to auto fill using option_name
additional_sizer_dict (dict): Dictionary of additional checkbox to be added to the sizer
"""
self.sizer = self.create_sizer()

Expand Down Expand Up @@ -43,7 +55,7 @@ def create_display(self):
# Add children
self.add_children()

wx.CallAfter(self.show_children_sizers, None)
wx.CallAfter(self.on_choice, None)

def add_checkbox_sizer(self, checkbox_metadata, info_icon, button, riro=False):
temp_checkboxes = []
Expand All @@ -57,7 +69,7 @@ def add_checkbox_sizer(self, checkbox_metadata, info_icon, button, riro=False):
checkbox_sizer.Add(button, 0, wx.ALIGN_LEFT | wx.RIGHT, 10)
for checkbox in temp_checkboxes:
# Bind
checkbox.Bind(wx.EVT_CHECKBOX, self.show_children_sizers)
checkbox.Bind(wx.EVT_CHECKBOX, self.on_choice)
checkbox_sizer.Add(checkbox, 0, wx.ALL, 5) # Add to sizer + spacer below
if riro:
self.checkboxes_riro.extend(temp_checkboxes)
Expand All @@ -70,7 +82,7 @@ def add_children(self):
for child in self.children:
self.sizer.Add(child['object'].sizer, 0, wx.EXPAND)

def show_children_sizers(self, event):
def on_choice(self, event):
childrens_to_show = self.get_children_to_show()
for child in self.children:
if child['object'] in childrens_to_show:
Expand All @@ -94,6 +106,7 @@ def create_sizer(self):

def get_argument(self, checkboxes):
args = ""
{item['label']: item['option_value'] for item in self.checkbox_metadata}
for checkbox in checkboxes:
if checkbox.GetValue():
label = checkbox.GetLabel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def get_command(self):
else:
input_text_boxes = {name: input_text_box_list}

# TODO: Fix
cmd, output, load_in_overlay = get_command_dict(input_text_boxes)
command.extend(cmd)
return command, output, load_in_overlay
8 changes: 4 additions & 4 deletions fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def on_choice(self, event):
if selection == 'Dynamic/volume':
self.dropdown_slice_dyn.on_choice(None)
self.dropdown_coil_format_dyn.on_choice(None)
self.checkbox_scanner_order_dyn.show_children_sizers(None)
self.checkbox_scanner_order_dyn.on_choice(None)
self.dropdown_opt_dyn.on_choice(None)
elif selection == 'Realtime Dynamic':
self.dropdown_slice_rt.on_choice(None)
self.dropdown_coil_format_rt.on_choice(None)
self.checkbox_scanner_order_rt.show_children_sizers(None)
self.checkbox_scanner_order_rt.on_choice(None)
self.dropdown_opt_rt.on_choice(None)
else:
pass
Expand Down Expand Up @@ -228,11 +228,11 @@ def create_sizer_dynamic_shim(self, metadata=None):
},
{
"label": "1",
"option_value": "0,1"
"option_value": "1"
},
{
"label": "2",
"option_value": "0,1,2"
"option_value": "2"
}
]

Expand Down
2 changes: 1 addition & 1 deletion test/gui/test_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def set_dropdown_selection(dropdown_widget, selection_name):


def set_checkbox(checkbox_widget):
""" Sets the notebook terminal to the page with the given name."""
""" Sets the checkbox to True."""
checkbox_widget.SetValue(True)
wx.PostEvent(checkbox_widget.GetEventHandler(), wx.CommandEvent(wx.EVT_CHECKBOX.typeId, checkbox_widget.GetId()))
realYield()
Expand Down

0 comments on commit 34c2c50

Please sign in to comment.