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

Select widget #2501

Merged
merged 37 commits into from
May 8, 2023
Merged

Select widget #2501

merged 37 commits into from
May 8, 2023

Conversation

willmcgugan
Copy link
Collaborator

@willmcgugan willmcgugan commented May 5, 2023

  • Adds a Select widget.
  • Adds two new CSS rules. overlay: and constrain:.
  • Allows bindings to be set with two values.
  • Adds Region.translate_inside

Setting overlay: screen display a widget above everything else. Like there is an implicit top level layer.

Setting constrain: to x, y, or both ensures that the widget doesn't get clipped of the edge of the screen.

This two rules are undocumented as they are experimental. They simplify the implementation of pop-up controls like this Select widget. In the future we can also use them for auto-complete lists and tool tips.

Screen.Recording.2023-05-07.at.14.51.10.mov

@willmcgugan willmcgugan marked this pull request as draft May 5, 2023 15:52
@willmcgugan willmcgugan changed the title overlay rule Select widget May 7, 2023
@@ -38,6 +38,9 @@ class Message:
namespace: ClassVar[str] = "" # Namespace to disambiguate messages

def __init__(self) -> None:
self.__post_init__()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This allows creating messages from dataclasses.

@willmcgugan willmcgugan marked this pull request as ready for review May 7, 2023 20:08
Copy link
Contributor

@davep davep left a comment

Choose a reason for hiding this comment

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

Second coffee of the morning read-through and code play, couple of questions.

docs/widgets/select.md Outdated Show resolved Hide resolved
src/textual/binding.py Outdated Show resolved Hide resolved
src/textual/css/_styles_builder.py Show resolved Hide resolved
src/textual/css/_styles_builder.py Show resolved Hide resolved
src/textual/widgets/_select.py Outdated Show resolved Hide resolved
src/textual/widgets/_select.py Outdated Show resolved Hide resolved
src/textual/widgets/_select.py Outdated Show resolved Hide resolved
src/textual/widgets/_select.py Outdated Show resolved Hide resolved
src/textual/widgets/_select.py Outdated Show resolved Hide resolved
src/textual/widgets/_select.py Show resolved Hide resolved
willmcgugan and others added 3 commits May 8, 2023 10:17
Copy link
Contributor

@davep davep left a comment

Choose a reason for hiding this comment

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

Main questions resolved, looks good to go for me. Looking forward to making use of this.

I'm actually really taken by how good and smooth it all looks.

@willmcgugan willmcgugan merged commit 7db7139 into main May 8, 2023
@willmcgugan willmcgugan deleted the overlay branch May 8, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants