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

make ScrollBar check wrapped widgets for SupportsScroll (Fixes #878) #879

Merged
merged 5 commits into from
May 14, 2024

Conversation

rsekman
Copy link
Contributor

@rsekman rsekman commented Apr 30, 2024

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)
Description:

Fixes #878 .

urwid/widget/scrollable.py Outdated Show resolved Hide resolved
urwid/widget/scrollable.py Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Apr 30, 2024

Pull Request Test Coverage Report for Build 9075496246

Details

  • 9 of 10 (90.0%) changed or added relevant lines in 1 file are covered.
  • 64 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.04%) to 74.72%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/widget/scrollable.py 9 10 90.0%
Files with Coverage Reduction New Missed Lines %
urwid/widget/widget_decoration.py 7 80.6%
urwid/display/_raw_display_base.py 57 50.0%
Totals Coverage Status
Change from base Build 8873706490: 0.04%
Covered Lines: 9401
Relevant Lines: 12728

💛 - Coveralls

penguinolog: `w.original_widget` can point to `w`, we need to filter such behaviour to prevent infinite loop
if w in visited:
break
visited.add(w)
yield w
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are there decorations that are scrollable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://urwid.org/reference/widget.html#urwid.WidgetDecoration.base_widget exists to get the "most" .original_widget

Looking at the code, it is implemented like this generator was originally, i.e., vulnerable to infinite loops. So the fix in e5377cf should be applied also in widget_decoration.py, at least.

I have no idea if there are scrollable decorations; this is my first time working with the urwid code. It seems like a silly thing to implement, but if someone did they might be hit with an extremely confusing bug if we only check the base_widget.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are there decorations that are scrollable?

Scrollable is a decoration adding scroll support to the widgets:

class Scrollable(WidgetDecoration[WrappedWidget]):

Fix static checker warning
@penguinolog penguinolog merged commit d9a762d into urwid:master May 14, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ListBox wrapped in AttrMap is not scrollable with ScrollBar
4 participants