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

[BUG] urwid.Overlay valign doesn't accept relative any more #851

Closed
3 tasks done
geier opened this issue Mar 3, 2024 · 2 comments · Fixed by #854
Closed
3 tasks done

[BUG] urwid.Overlay valign doesn't accept relative any more #851

geier opened this issue Mar 3, 2024 · 2 comments · Fixed by #854

Comments

@geier
Copy link
Contributor

geier commented Mar 3, 2024

Description:

urwid.Overlay's valign doesn't accept values of ('relative', 50) any more, if though it should be fine according to the documentation. This used to work until 2.4.2

Affected versions (if applicable)
  • master branch ead68bb
  • Latest stable version from pypi
  • 2.4.3 and onwards (haven't tested every release, but 2.4.2 still works)
Steps to reproduce (if applicable)

This example program used to work with older versions of urwid (<=2.4.2) but breaks with current versions.

import urwid

text = urwid.Text("Hello, World!")
fill = urwid.Filler(text, 'top')

version = urwid.Text(f"This is urwid version: {urwid.__version__}")
filled = urwid.Filler(version, 'top')
overlay = urwid.Overlay(
    fill,
    filled,
    align='center',
    width=('relative', 60),
    valign=('relative', 50),
    height=('relative', 60),
)

loop = urwid.MainLoop(overlay)
loop.run()
Traceback (most recent call last):
  File "/Users/cg/workspace/khal/breaks.py", line 9, in <module>
    overlay = urwid.Overlay(
              ^^^^^^^^^^^^^^
  File "/Users/cg/workspace/khal/.venv/lib/python3.11/site-packages/urwid/widget/overlay.py", line 171, in __init__
    self.set_overlay_parameters(align, width, valign, height, min_width, min_height, left, right, top, bottom)
  File "/Users/cg/workspace/khal/.venv/lib/python3.11/site-packages/urwid/widget/overlay.py", line 527, in set_overlay_parameters
    self.options(
  File "/Users/cg/workspace/khal/.venv/lib/python3.11/site-packages/urwid/widget/overlay.py", line 430, in options
    VAlign(valign_type),
    ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: <WHSettings.RELATIVE: 'relative'> is not a valid VAlign
Expected/actual outcome

[...]

@geier geier added the bug label Mar 3, 2024
@penguinolog penguinolog self-assigned this Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog pushed a commit to penguinolog/urwid that referenced this issue Mar 4, 2024
penguinolog added a commit that referenced this issue Mar 4, 2024
Fix: #851

Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com>
@penguinolog
Copy link
Collaborator

Fixed, added tests to prevent regression in the future and updated docstrings/typing annotations.
Made urgent release.

@geier
Copy link
Contributor Author

geier commented Mar 4, 2024

Thank you very much for the incredibly quick fix and release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants