First feedback and many questions #1467
Replies: 1 comment 2 replies
-
I don't believe there's a good solution for that within Textual at the moment, but I seem to recall it's something we'd like to address at some point. However, Textual is built on top of Rich and Rich does have a solution for that.
If I'm understanding what you're asking here, I suspect the layout guide will be of help with this.
As you may have seen mention of in the docs, they're both pseudo-classes in CSS.
In a Textual application focus is moved around the focusable widgets using Tab (to move focus forward through the focusable widgets) and Shift+Tab (to move backwards through the focusable widgets). The user can also, of course, move focus to another widget by clicking on it with the mouse (or other pointing device), but that's also potentially going to perform that widget's main action too (if it has one -- think tabbing into a button vs clicking on a button, in a GUI UI). All of this comes out of the box with a Textual app; you don't need to do anything to allow or enable it. And the
From this, and other things you've said, I sense you maybe running into some confusion about how widgets and focus in general work. It's worth keeping in mind that most things in Textual are a That's made up of a growing list of containers, which show when focus is within them, and with buttons for actions that relate to the main thing being displayed, and also pulling the content from a third party API.
If you're using the list-of-tuples approach there's no support for that. For bindings you don't want to appear in the footer, use the
By default Button:focus {
text-style: bold reverse;
} You could override that in your own app's stylesheet.
You'll likely find your application is more responsive if you use async. I've personally found HTTPX to be a good drop-in replacement for requests that supports async.
No. |
Beta Was this translation helpful? Give feedback.
-
I treated myself with a Textual morning just to see how things feel with the new version, and wanted to report about fresh impressions before I forget them 😄
The objective is to construct a small app to explore Pocket bookmarks (I have a basic ncurses equivalent that I don't want to maintained), and in few hours I managed to reach the screenshot below.
I'll keep playing when I have some time, but although things are quite different from my first experiences, things are really easy to put in place now!
So, just in random orders, things I found easily, not so easily, not at all, etc.:
It was not so direct to think about how to clip some text on one line (found with
height: 1
in the CSS) => see URL fieldIn the end, I also added some width limitation, but I couldn't find a way to display that the URL has been clipped or not (like maybe add some
...
sign after? is it possible in the CSS?)Also, not so easy to find out how to put two elements on the same line: the title and the date on the screenshot. I always had one field or the other, until I understood I had to constrain their width; otherwise they overlap and you don't get how things are doing...
I didn't get whether I should use
Button
or not for each entry; in the end I did when I tried to handle focus and clicks, but maybe it was not necessary; that's still blurry for me hereI am also a bit confused between
:hover
and:focus
; the thing in the end is that I would like to move the focus on each "button"/entry with the keyboard as well, but I am not sure how to do so; I don't know whether I get the id of the entry who got the focus from the Python code and move it programmatically when the mouse is not moving any more. That's the next thing on my todo list; all actions I want to implement next are based on the entry which got the focus (mouse or keyboard)edit: found about
.has_focus
and.focus()
to do the job (through autocompletion...)I couldn't find how to force buttons to get the focus and hover when the mouse is over the text in the button (I can only gain focus/hover when the pointer is not on sub-elements of the widget)
I couldn't find how to hide some bindings from the footer, tried
None
,False
, etc. naturally, but it didn't work (for example, I planned to hide down/up)I also don't like the way text in buttons which got the focus has this background colour, but couldn't find how to deactivate it :/
When I go further and implement actions, some of them will require http queries; should I use an async library or can I stick with requests?
I found about
poetry run textual run --dev path.to.module:Class
but it's not documented (only thefoo.py:Class
is, but it doesn't work if you have relative imports in your .py)Are logs stored somewhere when you
self.log
? Couldn't find out...Beta Was this translation helpful? Give feedback.
All reactions