Skip to content

Commit

Permalink
Simplify handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpre committed Sep 27, 2024
1 parent d73c7f3 commit a3755ae
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions hyperspy_gui_traitsui/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hyperspy_gui_traitsui.utils import add_display_arg


class SmoothingHandler(tu.Handler):
class GenericHandler(tu.Handler):

Check warning on line 12 in hyperspy_gui_traitsui/tools.py

View check run for this annotation

Codecov / codecov/patch

hyperspy_gui_traitsui/tools.py#L12

Added line #L12 was not covered by tests

def close(self, info, is_ok):
# Removes the span selector from the plot
Expand Down Expand Up @@ -263,7 +263,7 @@ def smooth_savitzky_golay_traitsui(obj, **kwargs):
# 'line_color',
),
kind='live',
handler=SmoothingHandler,
handler=GenericHandler,
buttons=OKCancelButtons,
title='Savitzky-Golay Smoothing',
)
Expand All @@ -279,7 +279,7 @@ def smooth_lowess_traitsui(obj, **kwargs):
# 'line_color',
),
kind='live',
handler=SmoothingHandler,
handler=GenericHandler,
buttons=OKCancelButtons,
title='Lowess Smoothing',)
return obj, {"view": view}
Expand All @@ -293,7 +293,7 @@ def smooth_tv_traitsui(obj, **kwargs):
# 'line_color',
),
kind='live',
handler=SmoothingHandler,
handler=GenericHandler,
buttons=OKCancelButtons,
title='Total Variation Smoothing',)
return obj, {"view": view}
Expand All @@ -307,7 +307,7 @@ def smooth_butterworth(obj, **kwargs):
'order',
'type'),
kind='live',
handler=SmoothingHandler,
handler=GenericHandler,
buttons=OKCancelButtons,
title='Butterworth filter',)
return obj, {"view": view}
Expand Down Expand Up @@ -449,19 +449,6 @@ def remove_background_traitsui(obj, **kwargs):
return obj, {"view": view}


class BaselineRemovalHandler(tu.Handler):

def close(self, info, is_ok):
obj = info.object
obj.close()
return True

def apply(self, info):
"""Handles the **Apply** button being clicked."""
obj = info.object
obj.apply()


@add_display_arg
def remove_baseline_traitsui(obj, **kwargs):
view = tu.View(

Check warning on line 454 in hyperspy_gui_traitsui/tools.py

View check run for this annotation

Codecov / codecov/patch

hyperspy_gui_traitsui/tools.py#L452-L454

Added lines #L452 - L454 were not covered by tests
Expand Down Expand Up @@ -537,7 +524,7 @@ def remove_baseline_traitsui(obj, **kwargs):
tu.Group(
tu.Item(
'smooth_half_window',
enabled_when="_enable_smooth_half_windows",
enabled_when="_enable_smooth_half_window",
),
tu.Item(
'num_std',
Expand All @@ -562,8 +549,8 @@ def remove_baseline_traitsui(obj, **kwargs):
label="Classification",
),
),
buttons=[OKButton, CancelButton],
handler=BaselineRemovalHandler,
buttons=OKCancelButtons,
handler=GenericHandler,
close_result=False, # is_ok=False when using window close button.
title='Baseline removal tool',
resizable=True,
Expand Down

0 comments on commit a3755ae

Please sign in to comment.