News for hackers. Stuff that matters.
Re:NiceGUI – easy-to-use, Python-based UI framework by rodja on Saturday April 01, 2023 @02:09AM (#35397602)
Hi Ken_At_EM, thanks for looking into our code! Our approach with context managers for defining "belonging" in NiceGUI resembles the nesting of elements in HTML. By implementing the __enter__ and __exit__ methods, we can manage the context when used with a "with" expression. In NiceGUI, elements pass down to the default_slot (https://github.com/zauberzeug/nicegui/blob/main/nicegui/elem...), which is a 1:1 representation of Vue slots.

We maintain a slot stack (https://github.com/zauberzeug/nicegui/blob/main/nicegui/slot...) to keep track of the current context (see http://127.0.0.1:8080/documentation#auto-context). When creating a new element, it finds its parent slot on the slot stack (https://github.com/zauberzeug/nicegui/blob/main/nicegui/elem...).

What do you think. Does it make sense? We appreciate your feedback!

Re:NiceGUI – easy-to-use, Python-based UI framework by eyelidlessness on Saturday April 01, 2023 @03:04AM (#35397921)
> Hi Ken_At_EM […] see http://127.0.0.1:8080

Maybe imperative UI declaration needs a little extra care to keep its state consistent after all :D

Please take my silly glib response as a friendly jab not a meanspirited one… but this made me chuckle a couple times! Good luck with your project nonetheless