Search code examples
pythonwidgetjupyteripyvuetify

get value select from ipyvuetify


It's a very simple question, but I didn't find the solution. I use ipyvuetify and I would like to get the value from Select widget. For example, if I click on "Apple" I would like to get this value in an feature.

What is the workflow to get the value from, the widget in ipyvuetify ?

import ipyvuetify as v

def on_click(widget, event, data):
        print(widget, event, data)

a = v.Col(cols=4, children=[
            v.Select(label='Functions', items=['Apple', 'Pear', 'Cherry'], outlined=True)
        ])

a.on_event('click', on_click)
a

Thank you,


Solution

  • This has been answered here: https://github.com/mariobuikhuizen/ipyvuetify/issues/171

    import ipyvuetify as v
    import ipywidgets as widgets
    from ipywidgets import Layout
    
    def on_click(widget, event, data):
        print(a.v_model)
        print(widget, event, data)
    
    a = v.Select(
        v_model='',
        label='Functions', items=['Apple', 'Pear', 'Cherry'], outlined=False)
    
    a.on_event('change', on_click)
    a