Skip to content

Commit

Permalink
Simplify init
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Jul 23, 2024
1 parent e5c9e51 commit 19ba8af
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/napari_feature_visualization/feature_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,14 @@ def update_df_columns(event):
elif "index" in features:
widget.label_column.value = "index"

@widget.load_features_from.changed.connect
def switch_feature_load_mode(event):
# event value will be the new path
# get_df will give you the cached df
# ...reset_choices() calls the "get_feature_choices" function above
# to keep them updated with the current dataframe
widget.feature.reset_choices()
widget.label_column.reset_choices()
features = widget.feature.choices
if "label" in features:
widget.label_column.value = "label"
elif "Label" in features:
widget.label_column.value = "Label"
elif "index" in features:
widget.label_column.value = "index"

# if load_features_from is toggled, make the widget.DataFrame disappear
if widget.load_features_from.value == "Layer Properties":
widget.DataFrame.hide()
else:
widget.DataFrame.show()

widget.load_features_from.changed.connect(update_df_columns)

@widget.feature.changed.connect
def update_rescaling(event):
if widget.load_features_from.value == "CSV File":
Expand Down

0 comments on commit 19ba8af

Please sign in to comment.