Commit Graph

6314 Commits

Author SHA1 Message Date
Dave Pearson
56103c52e7 Ensure we log any OptionList messages in the messages test
We don't actually want to see them, we don't expect to see them, so here I
make a point of logging them so we can be sure we *don't* see them.
2023-05-24 09:09:40 +01:00
Dave Pearson
50d77b231f Add tests for the wrong sized tuple
While type checking picks this up, not everyone uses type checking.
2023-05-23 16:45:53 +01:00
Dave Pearson
9f6d35b871 Start unit tests for the actual selected property 2023-05-23 16:26:28 +01:00
Dave Pearson
c448fa1ea0 Add unit tests for selection list messages 2023-05-23 15:48:34 +01:00
Dave Pearson
f9780d0346 Add basic selection list creation unit tests 2023-05-23 15:13:46 +01:00
Dave Pearson
d38780ba97 Ensure we don't try and post messages before the widget is ready 2023-05-23 11:45:31 +01:00
Dave Pearson
d5799377a2 Document _selected
It's not for public consumption, but it's useful for anyone reading the code.
2023-05-23 11:31:07 +01:00
Dave Pearson
bee438bc53 Get the selection value tracker in place before calling the superclass 2023-05-23 11:30:04 +01:00
Dave Pearson
fefb33a23b Add a docstring to the internal copy of the selection value 2023-05-23 11:07:45 +01:00
Dave Pearson
81abac1c68 Tidy up some docstrings
Mainly adding missing return values, that sort of thing.
2023-05-23 10:46:00 +01:00
Dave Pearson
23d899935f Correct a docstring 2023-05-23 10:36:59 +01:00
Dave Pearson
ff404e2bbf Only refresh on deselect if something was deselected 2023-05-23 10:35:48 +01:00
Dave Pearson
d861cced97 Improve how the _all methods work
Deciding if there was a change when turning all on or off by looking at the
before an after counts was fine, but it's not a sensible way of seeing if
there was a change during a toggle. So this swaps things up a bit and has
the core selection changing methods return a flag to say if they actually
made a change or not.
2023-05-23 10:33:39 +01:00
Dave Pearson
db273ea9ff Add a method for toggling all options 2023-05-23 10:26:16 +01:00
Dave Pearson
a4148d028b Add a method for deselecting all options 2023-05-23 10:22:01 +01:00
Dave Pearson
3ce04c814a Add a method of selecting all selection options 2023-05-23 10:20:00 +01:00
Dave Pearson
a2fc3fad43 Add a method to apply a state change to all selection options 2023-05-23 10:19:20 +01:00
Dave Pearson
4c9afca8fd Add a docstring for the component classes. 2023-05-23 10:02:07 +01:00
Dave Pearson
195e9b4021 Add the docstring for the bindings 2023-05-23 09:50:44 +01:00
Dave Pearson
ca07d7a58d Fill in the blanks with docstrings
Adding back docstrings from overriding methods. Initially I was thinking it
made sense to keep them empty, allowing for any inheriting of the
docs (if/when our documentation generation system does that); but in most
cases there's a subtle difference in what's supported in terms of parameters
or return values so it makes sense to tweak the docs a wee bit.
2023-05-23 09:47:45 +01:00
Dave Pearson
9e6bf085b8 Extend add_option so that it accepts selections and selection tuples 2023-05-23 09:24:29 +01:00
Dave Pearson
f530efda2a Extend SelectionList.add_options to better support the selection list 2023-05-22 15:58:08 +01:00
Dave Pearson
68250e6ce3 Override _remove_option to update the selected values
The developer could remove an option that is selected, so we need to catch
that this has happened and update the collection of selected values.
2023-05-22 15:25:11 +01:00
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
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
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
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
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
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
c0b5832183 Explain things a wee bit better for the future reader 2023-05-18 16:34:30 +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
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
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