Make Slot class better #2303
Replies: 10 comments 6 replies
-
Thanks for bringing this up, @WolfgangFahl. The Regarding your suggestions:
|
Beta Was this translation helpful? Give feedback.
-
@falkoschindler thank you for looking into this.
and then mostly just the code with enter, exit and stack functionalities. It seems that This means you can use a Slot in a with statement, and when you exit the with block, the exit method is called automatically to clean up or finalize the slot. I already asked: Is it related to https://vuejs.org/guide/components/slots.html#slot-content-and-outlet and https://vuejs.org/guide/components/slots.html#named-slots as the properties name and template would suggest? 2: First of all the code should be debuggable so if the pop is not possible the code for this should be on a separate line to allow to set |
Beta Was this translation helpful? Give feedback.
-
if only the one liner self.get_stack().pop() would be replaced by a multiline version with the option to set a breakpoint to handle the case when self.get_stack() is empty ... |
Beta Was this translation helpful? Give feedback.
-
@falkoschindler The reason for this issue is to change the nicegui slot.py and improve it. I already changed the slot.py multiple times and will have to do it again and again on every release. |
Beta Was this translation helpful? Give feedback.
-
The problem is still happening. here is a recent example:
why would a with parent be able to cause this? What does Keep in mind that all UI updates must happen on the main thread with its event loop. mean? What is the necessary style/pattern to be applied here? |
Beta Was this translation helpful? Give feedback.
-
I am back at def __exit__(self, *_) -> None:
stack=self.get_stack()
if not stack:
pass
stack.pop()
self.prune_stack() which at least allows debugging ... it would be good to have a setting that allows to have some kind of debug/warning mode in which it is pointed out how typical scenarios look like in which the problem above may happen. In my case it was simply a call: with parent:
yp_cell_card=ui.card()
label_text = yp_cell.getLabelText()
checkbox = self.create_simple_checkbox(
parent=yp_cell_card,
label_text=label_text,
title=label_text
) versus with parent:
yp_cell_card=ui.card()
label_text = yp_cell.getLabelText()
checkbox = self.create_simple_checkbox(
parent=yp_cell_card,
label_text=label_text,
title=label_text
) for some reason or another to nested with parent won't work ... and the with parent in create_simple_checkbox is not obvious from the code above. Such small typos/glitches easily lead to the Slot class throwing an error that looks strange. |
Beta Was this translation helpful? Give feedback.
-
@rodja self.get_stack().pop() may fail since get_stack() might deliver an empty stack. To make the software more robust a check is IMHO needed. The software will then at least not immediately crash. My solution is currently to offer a debug break point for developers which does nothing but allows to set catch the situation when debugging. Having a general option for such debugging or security/robustness checks might be an improvement. |
Beta Was this translation helpful? Give feedback.
-
@rodja |
Beta Was this translation helpful? Give feedback.
-
This is something we are facing a lot in |
Beta Was this translation helpful? Give feedback.
-
@MaidScientistIzutsumiMarin Thank you for reminding. The hints are much better these days https://ngdemo.bitplan.com/taskrunner and #2729 are updated |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The class Slot needs:
should not lead to
IndexError: pop from empty list
see #1786
Beta Was this translation helpful? Give feedback.
All reactions