ipyaladin icon indicating copy to clipboard operation
ipyaladin copied to clipboard

Listeners functions do not catch their trigger if the widget is not fully loaded

Open ManonMarchand opened this issue 2 years ago • 3 comments

What happens

Sometimes, the widget has not finished loading when the user attempts to call one of the listeners functions (add_table, target...) This can be trigered in two ways:

  • users call the listeners in the same cells than the widget
  • use of automatic executions of cells (like in testing or regeneration tools)

Possible ideas for fixes

  • Implement an await on python side or async on javascript side?
  • Rework the way we handle listenners

ManonMarchand avatar Jun 06 '23 10:06 ManonMarchand

Refer to this doc for the choice of the solution : https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Low%20Level.html

ManonMarchand avatar Jun 06 '23 12:06 ManonMarchand

Update: await on python side is a dead end.

ManonMarchand avatar Aug 30 '23 15:08 ManonMarchand

Update2: doing the flag change in a thread as suggested here https://ipywidgets.readthedocs.io/en/7.6.5/examples/Widget%20Asynchronous.html did not work neither

import threading
thread = threading.Thread(target=exec, args=("self.update_wcs_flag = not self.update_wcs_flag", {'self': self}))
thread.daemon = True
thread.start()

ManonMarchand avatar Aug 31 '23 09:08 ManonMarchand