Resetting value after setting options in ListBox
See original GitHub issueDescribe 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:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Easy fix - tested and has the desired effect on value. Your code should now work with master branch.
Now I figured out what the line was for. Your fix sounds good.