Create a decorator to loading buttons and raise errors on Alerts #175
Replies: 2 comments 1 reply
-
this is not the first time you surprise me with decorators and it seems super nice. I still have a lot to learn about python
|
Beta Was this translation helpful? Give feedback.
-
I was also thinking this morning, It would really be much more functionnal if we can directly apply the decorator on the function that is called by the btn. Sometime you may want to add multiple actions in the try exept which would force us with this method to have 1 function to link the btn, 1 function for the decorator, X function to call inside the decorated function. I'm affraid it's too much layers ;-) I tried to drive Rémi this week to build his second module (https://github.com/lecrabe/tmf_sepal) and we need to keep in mind thats some people that will use the "sepalizer" will be scientists with very little background in Python or POO. |
Beta Was this translation helpful? Give feedback.
-
While developing some modules, I've been using the same pattern to display errors (try, except), and toggle loading the event buttons, so I decided to create a decorator to wrap all this process, so I'm starting this discussion to incorporate it as native sepal_ui feature, and so you @12rambau can help me to make it stronger...
This is what I have:
Use in a class:
The errors will be displayed on the alert widgets, however, they are also displayed in the IPython interface, but not when launched by voilá, this could be a good thing for debug purposes, or we can also create a capture decorator inside the loading decorator, so we can display the error thread wherever we want.
Beta Was this translation helpful? Give feedback.
All reactions