question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow Select to accept non-string option values

See original GitHub issue

I think it would be useful to have the Select widget values to be any object: for example it maybe useful for the select.value to point to a function.

Consider this (hypothetical) instance of a Select widget:

select = Select(title="Options:",
                value=do_1,
                options=[(do_1,"option_1"), (do_2,"option_2"), (do_3,"option_3"), (do_4,"option_4")])

where do_n is a previously defined function. I have chosen to have (value, label) pairs as options so a user could select an option and the relevant function could be accessed by accessing the value attribute of my widget (i.e., select.value). Currently this isn’t supported and I will have to store my functions in a dictionary with suitable keys selected by the widget.

There is a related issue (bug?) that the value attribute fed to initiate the Select widget can only be a String. It would be nice to to support this kind of functionality:

select = Select(title="Options:",
                value=1,
                options=[(1,"option_1"), (2,"option_2"), (3,"option_3"), (4,"option_4")])

Currently this does not work but in some instances is required (i.e., when using the select widget to access a list and a default value is required).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, May 9, 2019

Do you mean raise a bug report?

@FChmiel no I think I misinterpreted this:

There is a related issue (bug?) that the value attribute fed to initiate the Select widget can only be a String. It would be nice to to support this kind of functionality:

to mean there is a related GH issue here somewhere.

This issue is great for figuring out how to expand supported values in Select

1reaction
jbednarcommented, May 9, 2019

The Param library works like this, with the value of a Selector being an actual item (integer, function, etc.) and the Panel library being used to make a corresponding Bokeh widget. See e.g. the select_fn parameter in the Panel Param docs. This doesn’t change whether Bokeh itself could or should act like this, but I think it does let you do the sort of thing you’re asking for, and it might be an approach to consider.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can the select option value be of different types?
No, it can be CDATA. You might parse it into a string, float, etc on the server, but it isn't in that state...
Read more >
<select>: The HTML Select element - HTML - MDN Web Docs
A Boolean attribute indicating that an option with a non-empty string value must be selected. size. If the control is presented as a ......
Read more >
Getting and Setting | Vue Select
The value prop lets vue-select know what value is currently selected. It will accept strings, numbers or objects. If you're using a multiple...
Read more >
Form Select | Components - BootstrapVue
In non multiple mode, <b-form-select> returns the a single value of the currently selected option. Please select some item, This is First option,...
Read more >
Select - Ant Design
Select component to select value from options. When To Use. A dropdown menu for displaying choices - an elegant alternative to the native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found