Skip to content

Range Fields #3

@mfitzp

Description

@mfitzp

In Python 3 a range(0,10,3) creates a range object rather than a list. We can make use of this to display a range-specific UI element such as slider.

This will require additions to clinto to detect and pass the object type and parameters somehow.

In flask-wooey this was handled and passed as follows:

jsons = []
for action, widget in filtered_actions:
    if PY3 and isinstance(action.choices, range):
        widget = 'RangeField'
        action.choices = (action.choices.start, action.choices.stop, action.choices.step)
    elif action.nargs == "+":
        # FIXME: We can be smarter here; other possibilities for multiple selections
        widget = 'SelectMany'
    else:
        widget = 'SelectOne'

    jsons.append(as_json(action, widget=widget))

return jsons

Since range supports integers only it might make sense to implement this as a range type in TYPE_FIELDS? The parameters for the range can then be passed to the field definition.

wooey/django-djangui#9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions