-
Notifications
You must be signed in to change notification settings - Fork 822
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
Add LedDisplay widget #2990
Add LedDisplay widget #2990
Conversation
Here is a first attempt of implementation for a widget to display 7-segment display-like digits and more. This works for digits all in the same line, but it needs to be adapted for the cases where the digits don't fit.
So this implementation works for digits in the same "line": It breaks when the digits fall outside the "line": I would love to be able to use CSS to solve this problem, since it seems the perfect job for I tried creating a compound widget with that idea, but ran into two problems:
I will try to continue on this idea, but would love to hear if anyone has any better idea on how to do this. |
src/textual/widgets/_led_display.py
Outdated
""" | ||
|
||
# here we strip spaces and replace underscores with spaces | ||
_character_map = {k: v.strip() for k, v in _character_map.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably save a bit of time if we replace the underscores with spaces right away, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, updated!
I believe you can't really re- Maybe the solution is just to truncate on one end if it doesn't fit. @willmcgugan what do you think? |
2374072
to
761b987
Compare
Right, I ended up figuring out the The current implementation doesn't break visually anymore, now the content that doesn't fit is overflowing outside the screen. |
Code of testing app:
|
bf842b6
to
020c744
Compare
Hey Elias, this is looking awesome! Given your most recent screenshot, it looks like the led display is now taking up 4 rows, and the bottom one is only used for the letters |
Thank you! And yes, you're correct!
I wanted to talk to you about that, I imagine there are better ways.
I'm heading to the sprints now, we can talk in person in a bit. :)
-- Elias Dorneles
On July 23, 2023, flaviaerius ***@***.***> wrote:
Hey Elias, this is looking awesome! Given your most recent screenshot,
it looks like the led display is now taking up 4 rows, and the bottom
one is only used for the letters fgjpqy?
—
Reply to this email directly, view it on GitHub
<#2990 (comment)-
1646776774>, or unsubscribe
<https://github.com/notifications/unsubscribe-
auth/AAAJFPIFRGXNRM4Y7CTSDYDXRTMKRANCNFSM6AAAAAA2T4ISNE>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Okay, so I've improved several characters of the "font", and I've added an Here's what's looking like: I believe this is good for a 95%-ready review, can you have a look? What's next:
|
Looks amazing, but you may have gone a little over and above the requirements there! We were looking for a widget that does digits, i.e. 0-9, with a few additional symbols like decimal point to display numbers. You've been very creative with regards to letters, but some just don't work to well with the very limited number of block characters. They are also limited to the Western alphabet, which is a problem for a framework designed for a global audience. And it would be nigh on impossible to represent all European alphabets, never mind CJK characters. Sadly, for these reasons I don't this belongs in the core library. However it is undeniable cool so maybe you could publish it as an external packages on PyPI? Perhaps |
Just to clarify, we're still interested in the core, something like Will just doesn't want all of your remaining work to go to waste, and that's why he suggested you create a package with all of your characters. |
Right, I get that, indeed I got a bit carried over with the excitement 😂 I believe it makes sense actually for this to be a separate package, I think doing this properly would mean to accept multiple "fonts", like figlet does, but with better fonts because we can use Unicode blocks. Okay, so I will make a new PR with a widget for the core, as you're going for arithmetic operators, I propose the widget in core could have these characters: Here's what they look like: What do you think? Anything to add or remove there? @rodrigogiraoserrao @willmcgugan |
Closing this in favor of: #2995 |
Here is a first attempt of implementation for a widget to display 7-segment display-like digits and more.
This works for digits all in the same line, but it needs to be adapted for the cases where the digits don't fit.
Please review the following checklist.