Commit Graph

6466 Commits

Author SHA1 Message Date
Dave Pearson
189181ba33 Add support for sending a message when the selection list changes
The developer using this may wish to react to UI changes being made, but
they may also want to just know when the collection of selected values has
changed -- this could happen via code so won't get any UI/IO messages. So
this adds a message that is always sent when a change to the collection of
selected values happens.
2023-05-22 15:23:11 +01:00
Dave Pearson
a25ef78a7f Fully hint the type of the selection list in mesages 2023-05-22 15:02:32 +01:00
Dave Pearson
13e796bfea Ensure selections are only one line in length 2023-05-22 14:56:21 +01:00
Rodrigo Girão Serrão
724fedc442 Merge pull request #2621 from Textualize/leave-footer-push-modal-screen
Leave footer when pushing modal screen
2023-05-22 14:43:05 +01:00
Rodrigo Girão Serrão
d48a127ffe Merge pull request #2540 from Textualize/screen-modes
Implements screen modes
2023-05-22 14:27:35 +01:00
Rodrigo Girão Serrão
c64111bcb5 Add property alias.
Related comment: https://github.com/Textualize/textual/pull/2540\#discussion_r1196634789
2023-05-22 14:21:11 +01:00
Dave Pearson
51d1dade5c Ensure access to options is actually access to selections 2023-05-22 14:18:20 +01:00
Dave Pearson
07515e22c8 Add an interface for changing selections from code 2023-05-22 14:01:09 +01:00
Rodrigo Girão Serrão
c32d5d3c25 Add regression test for #2606. 2023-05-22 13:53:58 +01:00
Dave Pearson
dae0cd7c02 Raise a widget-specific exception when given a bad option 2023-05-22 13:21:25 +01:00
Dave Pearson
1d925da551 Ensure selection casting works in earlier Pythons 2023-05-22 13:20:49 +01:00
Dave Pearson
127d93a260 Remove a couple of annoying type errors
The code worked and was fine, but pyright was getting upset at the typing.
This clears that up.
2023-05-22 13:13:37 +01:00
Rodrigo Girão Serrão
33a470f569 Fix footer highlight when pushing modal. 2023-05-22 11:45:40 +01:00
Dave Pearson
424c30fcf1 Add a method of getting at the selected values 2023-05-22 11:40:03 +01:00
Dave Pearson
6bc2a6ebd2 Add support for a selection message
In doing so, change up how the toggling happens.
2023-05-22 11:25:56 +01:00
Dave Pearson
41b1c08db5 Docstring tweak 2023-05-22 11:16:17 +01:00
Dave Pearson
4dab6d3b57 Start the SelectionList messages
It would be nice to just inherit form the OptionList messages, but the
naming of the properties wouldn't quite make sense, and there's also the
generic typing issue too. So here I start to spin up my own messages down
here.

Also, as an initial use of this, grab the OptionList highlight message and
turn it onto one of out own.
2023-05-22 11:09:18 +01:00
Rodrigo Girão Serrão
5c1c62edd0 Merge pull request #2607 from Textualize/placeholder-cycle
Placeholder color cycle
2023-05-22 10:50:11 +01:00
Rodrigo Girão Serrão
4e86e655d6 Merge branch 'main' into placeholder-cycle 2023-05-22 10:43:12 +01:00
Rodrigo Girão Serrão
5e04a4d4de Add description to work decorator. (#2605)
* Add description to work decorator.

* Fix stutter.
2023-05-22 10:32:23 +01:00
Dave Pearson
a570b4403e Swap the order of the prompt and value for selection items
Mostly I feel it makes sense to have the value first, and the actual prompt
second (based on no reason at all); but given that Select does it prompt
then value, this should conform to the same approach.
2023-05-22 10:30:22 +01:00
Luper Rouch
33da5c1afc Fix App.BINDINGS type (#2620)
The implicit type was creating mypy errors when defining bindings with
tuples. For example:

    class MyApp(App):
        BINDINGS = [("q", "quit", "Quit")]

Would give the error:

    error: List item 0 has incompatible type "Tuple[str, str, str]"; expected "Binding"  [list-item]
2023-05-22 10:27:31 +01:00
Dave Pearson
8339e8b513 Merge branch 'main' into multiselect 2023-05-22 09:49:39 +01:00
Will McGugan
7d0d1ac5c8 Bump0260 (#2617)
* full map

* docstring changelog

* changelog

* simplify, add comment
v0.26.0
2023-05-20 11:30:42 +01:00
Dave Pearson
7dd05e3ec0 Let child classes of DirectoryTree override Path creation
With #1719 in mind, and as an alternative to #2608, this allows for a child
class of DirectoryTree to specify how a fresh `Path` should be created. The
idea here being that whatever is created should be of the `Path` type, but
can have other abilities.
2023-05-19 10:15:04 +01:00
Dave Pearson
c0b5832183 Explain things a wee bit better for the future reader 2023-05-18 16:34:30 +01:00
Rodrigo Girão Serrão
6523fbaff1 Fix tests. 2023-05-18 16:27:09 +01:00
Rodrigo Girão Serrão
c85e428228 Fix placeholder color cycling. 2023-05-18 16:24:07 +01:00
Dave Pearson
6bea9f86d3 Sprinkle bold over all the buttons
At some point I should go through these styles and start to collapse/dedupe
them.
2023-05-18 16:22:47 +01:00
Dave Pearson
bc126ce036 Build the selection list back in __init__ again
Now that I'm no longer having to dodge issues with getting component classes
before the DOM has spun up, I can go back to the simpler method of setting
up the selections.

This also means I can drop Mount handling.
2023-05-18 16:20:32 +01:00
Rodrigo Girão Serrão
75606c8dfd Add explicit sleep. 2023-05-18 16:11:02 +01:00
Dave Pearson
12416d81d1 Remove unused import of Text 2023-05-18 15:42:45 +01:00
Dave Pearson
beb3645aa1 Remove Selection's knowledge of its parent
This isn't needed any more now that I'm doing everything in render_line.
2023-05-18 15:41:14 +01:00
Dave Pearson
b63e85f81c Remove _make_label
I don't need this any more.
2023-05-18 15:39:59 +01:00
Dave Pearson
8459a8c4f9 Swap to overriding render_line
More experimenting with overriding OptionList, and rather than trying to
swap out and around the prompt under the hood, I got to thinking that it
made more sense to perhaps override render_line.

So far so good...
2023-05-18 15:20:01 +01:00
Rodrigo Girão Serrão
ad986b127d Merge branch 'main' into screen-modes 2023-05-18 15:11:21 +01:00
Rodrigo Girão Serrão
d65daf81c0 Address review comments. 2023-05-18 15:07:52 +01:00
Rodrigo Girão Serrão
97f30a21fb Add tests. 2023-05-18 14:50:28 +01:00
Rodrigo Girão Serrão
bfdaf02f66 Add snapshot test. 2023-05-18 14:26:32 +01:00
Rodrigo Girão Serrão
03a43521dd Fix test. 2023-05-18 14:02:51 +01:00
Rodrigo Girão Serrão
0c520f13ce Change naming. 2023-05-18 13:58:59 +01:00
Rodrigo Girão Serrão
f464241fd6 Implement auto-completion. 2023-05-18 13:41:37 +01:00
Dave Pearson
0c18839c8a WiP selection list
I think I'm going to give up on basing this off OptionList. It's close
enough that inheriting from it and doing more makes some sense, but it's
also just far enough away that it's starting to feel like it's more work
that is worthwhile and it'll be easier to hand-roll something fresh.
2023-05-18 13:00:23 +01:00
Will McGugan
49e1080279 update howto 2023-05-18 10:03:26 +01:00
Will McGugan
8fd5aec454 fix layout 2023-05-18 09:28:33 +01:00
Dave Pearson
9d0a6d8eac Merge branch 'main' into multiselect 2023-05-18 08:56:11 +01:00
Will McGugan
ff5665051b Release0250 (#2598)
* version bump

* changelog
v0.25.0
2023-05-17 16:30:36 +01:00
Rodrigo Girão Serrão
a9c8b59df5 Use default string on error inside work. (#2595)
Related issues #2588.
2023-05-17 16:27:32 +01:00
Dave Pearson
84de8a8949 Typo fix (#2596) 2023-05-17 16:26:33 +01:00
darrenburns
e25c6290ba Add classes to Tab widget (#2589)
* Add classes to Tab widget

* Update CHANGELOG
2023-05-17 16:21:32 +01:00