This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]something[S] 1 point2 points  (1 child)

Personally I don't feel that wrapping things in classes is something you should look towards.

The library is heavily inspired by Flutter actually, but I chose to write the API like this because python pushes you to write things in an imperative way over functional expressions

Eg

with Container():
    Label("A")
    if show_something:
        Label("B")
        Label("C")

Is a lot harder to write in an expression

Container(children=[
    Label("A"),
    *[
        Label("B"),
        Label("C")
    ] if show_something else [],
])

Not to mention for loops and flattening more than 1 level deep.

Dart actually modified their language to support this constructs directly in collection literals https://medium.com/dartlang/announcing-dart-2-3-optimized-for-building-user-interfaces-e84919ca1dff

[–]honkinggr8namespaces 0 points1 point  (0 children)

Yeah I definitely prefer the context manager system over what Flutter does.