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.

Resetting value after setting options in ListBox

See original GitHub issue

Describe the bug In case of options updates, it is impossible to select any other than 0 value in ListBox. Along with the ListBox options setting happens: self.value = self._options[0][1]

To Reproduce

class CommonView(Frame):
    def __init__(self, screen):
        super(CommonView, self).__init__(
            screen,
            screen.height * 2 // 4,
            screen.width * 2 // 4,
            hover_focus=True,
            can_scroll=False,
            title='Title',
        )
        self._operations = [('Oper0', 0), ('Oper1', 1)]
        self._device_list = ListBox(
            Widget.FILL_FRAME,
            self._operations,
            add_scroll_bar=True,
            on_select=self._select)
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._device_list)
        self.fix()

    @property
    def frame_update_count(self):
        return 20

    def _update(self, frame_no):
        super()._update(frame_no)
        self._device_list.options = get_updated_device_list()

    def _select(self):
    for path, i in self._device_list.options:
        if i == self._device_list.value:
            raise Exception(i, path)

Expected behavior Correct selection of any item from the ListBox

Actual behavior After selection any item, the value is the value of the first item in ListBox.

Details:

  • Asciimatics 1.11.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
peterbrittaincommented, Oct 3, 2019

Easy fix - tested and has the desired effect on value. Your code should now work with master branch.

0reactions
egakupicommented, Oct 3, 2019

Now I figured out what the line was for. Your fix sounds good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List Box Reset not working - Power Platform Community
For ListBox, in order to make the Reset work, please take a try to set a value from the ListBox option (value within...
Read more >
Reset (Clear) ListBox selection (selected values) using ...
Here Mudassar Ahmed Khan has explained with an example, how to reset (clear) ListBox selection (selected values) using JavaScript and jQuery.
Read more >
how to clear reset selected item in listbox in javascript - YouTube
resetlistbox #javascriptlistboxclear#listboxitemsclearreset or clear the selected items in a listbox select option html element using ...
Read more >
Refreshing the listbox item after an element is changed
You can change the selected item by remove it and insert it again. ... My solution: string[] nList = new string[lb.Items.Count]; nList =...
Read more >
Resetting the values of a list box - MATLAB Answers
I have tried set(handles.Iso_pum1, 'value', 1) in a number of locations in the code, but this just keeps the value of the listbox...
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