pysepal.scripts.thread_controller.TaskController#

class pysepal.scripts.thread_controller.TaskController(function, callback=None, alert=None, start_button=None, stop_button=None, disable_components=None, *function_args, **function_kwargs)[source]#

Initializes the TaskController.

Parameters:
  • function (Callable) – The long-running function to execute.

  • callback (Callable | None) – A function to call with the result after the task completes.

  • alert (Alert | None) – An optional alert widget for displaying messages.

  • start_button (Btn | None) – An optional button to start the task.

  • stop_button (Btn | None) – An optional button to stop the task.

  • disable_components (List | None) – A list of components to disable while the task is running.

  • *function_args – Positional arguments for the function.

  • **function_kwargs – Keyword arguments for the function.

Methods

__init__

Initializes the TaskController.

set_components_enabled

Enables or disables UI components.

start_task

Starts the long-running task in a separate thread.

stop_task

Signals the task to stop.

TaskController.__init__(function, callback=None, alert=None, start_button=None, stop_button=None, disable_components=None, *function_args, **function_kwargs)[source]#

Initializes the TaskController.

Parameters:
  • function (Callable) – The long-running function to execute.

  • callback (Callable | None) – A function to call with the result after the task completes.

  • alert (Alert | None) – An optional alert widget for displaying messages.

  • start_button (Btn | None) – An optional button to start the task.

  • stop_button (Btn | None) – An optional button to stop the task.

  • disable_components (List | None) – A list of components to disable while the task is running.

  • *function_args – Positional arguments for the function.

  • **function_kwargs – Keyword arguments for the function.

TaskController.set_components_enabled(enabled)[source]#

Enables or disables UI components.

Parameters:

enabled (bool)

TaskController.start_task(*args)[source]#

Starts the long-running task in a separate thread.

TaskController.stop_task(*args)[source]#

Signals the task to stop.