Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pile default focus not handled well when contents is modified #492

Open
vapier opened this issue Dec 31, 2021 · 1 comment
Open

Pile default focus not handled well when contents is modified #492

vapier opened this issue Dec 31, 2021 · 1 comment
Labels
Feature Feature request/implementation Widget

Comments

@vapier
Copy link
Contributor

vapier commented Dec 31, 2021

to reproduce:

import urwid
# Create a Pile with no focusable element.
pile = urwid.Pile([urwid.Divider('-')])
# Add a focusable element.
pile.contents.append((urwid.Edit(edit_text=''), ('weight', 1)))
# Send a keypress.
pile.keypress((1,), 'enter')

at this point it crashes

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/urwid/container.py", line 1626, in keypress
    key = self.focus.keypress(tsize, key)
AttributeError: 'Divider' object has no attribute 'keypress'

if the focus is changed manually first via pile.set_focus(1), then there is no crash.

what makes this annoying is that if all the elements were added during initialization, then the focusable element (Edit) would have been selected automatically instead.

should Pile handle default focus better ? or should this be documented as WAI ?

@penguinolog penguinolog added the Feature Feature request/implementation label Apr 3, 2023
@penguinolog
Copy link
Collaborator

Marking as feature request due to automatic focus recalculation is not implemented in several widgets by design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request/implementation Widget
Projects
None yet
Development

No branches or pull requests

2 participants