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.

Selection of items from `SelectMultiple` is broken after content update via observe.

See original GitHub issue

My goal is to have two widgets, select and other that accept a list of options.

select may only take on one value, so I chose the RadioButtons widget for this. other may take on multiple values, so I used SelectMultiple. Further, the options available in other may not contain the value chosen in select. Ideally (but optionally), the selected items in other should be cleared when a new item is chosen from select.

I used widget.observe to update other when select changes, however (here’s the bug) the selection area in the SelectMultiple does not respond correctly to clicks after updates. For example, when I click one value, another becomes highlighted, or when I select a range an alternate set of values becomes selected. The behavior is erratic and inconsistent, so you might have to try a few times to get it to misbehave.

This code updates the content of other when the selection of select is altered:

from ipywidgets import SelectMultiple, RadioButtons, interact
options = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']

select_widget = RadioButtons(options=options)
other_widget = SelectMultiple(options=sorted(list(set(select_widget.options).difference(set([select_widget.value])))),
                              selected_labels=())
other_widget.selected_labels = ()

def update_other(*args):

    other_widget.value = ()
    other_widget.selected_labels = ()
    other_widget.options = list(set(select_widget.options).difference(set([select_widget.value])))

select_widget.observe(update_other)

def printer(select, other):
    print(select, other)

interact(printer, select=select_widget, other=other_widget, __manual = True)

Thank you, Mike

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jasongroutcommented, Nov 5, 2016

I just tried both examples with current master (6.0.0b2 + some commits), and they seem to work fine.

I did notice another bug, which I fixed: #883.

0reactions
gnestorcommented, Nov 8, 2016

I can verify that it’s working on master. I’m closing. Re-open if you see this in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get all selected values of a multiple select box?
How can I get this element's selected values using JavaScript? Here's what I'm trying: function loopSelected() { var txtSelectedValuesObj = document.
Read more >
Editing multiple issues at the same time | Jira Software Data ...
For example, if you select multiple issues with different workflows, ... right-click the selected items to start the bulk change operation.
Read more >
Edit multiple records in a list using the list editor
Select the records you want to edit by performing one of the following actions. To select multiple consecutive fields, hold Shift and drag...
Read more >
How to select DropDown in Selenium using Select ... - Tools QA
As highlighted in the above figure, the Select class of Selenium WebDriver provides the following methods to select an option/value from a ...
Read more >
HTMLSelectElement - Web APIs | MDN
Chrome Edge HTMLSelectElement Full support. Chrome1. Toggle history Full support. Edge12. To... add Full support. Chrome1. Toggle history Full support. Edge12. To... Index as before parameter...
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