TexteaInc/funix

widget type in decorator

Opened this issue · 3 comments

Can we allow users to specify the widget type in the decorator?

TURX commented

What do you mean by "widget type"? Is it the choice of some styles to display on frontend?

No. A slider is a widget. A radio button is a widget.
Widget is a concept in GUI. See examples here. https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html

We currently support the widget type.

For example:

@textea_export(
    a={
        "treat_as": "config",
        "widget": ["switch"]
    }
    ...
)

This will render a as a switch, and you can change widget to ["checkbox"], it will render a as a checkbox.

The widget syntax is: [top level, second level, ...] (Or string like switch, just for elements like the config)

For example: ["simple", "slider[0, 100, 5]"]

It means that the top-level widget is simple, and all elements in simple will be rendered as slider.

And you can customize the widget style corresponding to the basic type by setting the theme, for example:

types:
  float, str: input
  int: slider
  bool: switch

It means float and str will be rendered as input, int will be rendered as slider, and bool will be rendered as switch.