textual
textual copied to clipboard
Add the ability of changing class attributes at the moment of widget Instanciation.
edit: I wasn't aware of how that Reactive descriptor works. Now, I am familiar with how it works.
I think it is worth allowing programmers to have control over the value of class attributes at the moment of widget Instanciation. Take the following as an example:
class AwesomeWidget(Widget):
content: Reactive[str] = Reactive(default="")
name: Reactive[str] = Reactive(default="")
I need to have the ability to provide values at the Instanciation phase:
awesome_widget = AwesomeWidget(name='awesome widget', content='awesone content')
Probably it can be accomplished by doing something similar to attrs:
class AwesomeWidget(Widget):
content: Reactive[str] = Reactive(default="", init=True)
name: Reactive[str] = Reactive(default="", init=True)
edit: i knew that it can be done with __init__, but i don't want to add boilerplate to the code base:
class AwesomeWidget(Widget):
content: Reactive[str] = Reactive(default="", init=True)
name: Reactive[str] = Reactive(default="", init=True)
def __init__(self, name: str, content: str):
super().__init__(name)
self.content = content
self.name = name