Commit graph

302 commits

Author SHA1 Message Date
Will McGugan
b0f5c35782
tabs widget (#2020)
* tabs widget

* click underline

* color tweak

* docs

* docs update

* expose Tab

* added remove_tab and clear

* fix cycling

* add animation

* docs

* changelog

* remove recompose

* docstrings

* Update docs/guide/actions.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Rodrigoed the tabs

* Update docs/widgets/tabs.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/widgets/tabs.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* copy

* docstrings

* docstring

* docstring

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* stop click

* docstring

* auto assign consistent IDs

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Document bindings

* document bindings

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-13 14:39:15 +00:00
Will McGugan
9c5e0336f8
Fix scrollbar (#2024)
* Fix scrollbar

* changelog PR

* fix snapshots
2023-03-13 10:39:14 +00:00
Will McGugan
198190117d
Loading indicator (#2018)
* loading indicator and tests

* docs

* snapshot

* remove snapshot

* remove debug main [skip ci]

* changelog [skip ci]

* make start time private
2023-03-11 08:36:13 +00:00
Dave Pearson
97a5478bd0
Add ContentSwitcher (#1983)
* Add the basic ContentSwitcher widget

* Docstring tidy

* Add a visible_content property to the ContentSwitcher

* Clarify that children of ContentSwitcher with no IDs get ignored

* Simplify setting the display value

* Add the start of an example ContentSwitcher for the docs

* Tweak the example layout to better fit in small spaces

* Add the content switcher to the API docs

* Add a guide entry for the ContentSwitcher

This one is a wee bit more involved than most other widget entries in the
guide in that it doesn't obviously do anything itself, but needs
developer-input to make it do something useful. As such the outline here
isn't as clean as it could be, but I think it conveys everything necessary
without getting too complicated.

* Add the reactive attribute table to the ContentSwitcher guide

* Update the README

* Add a refresh after everything has been flipped in the switcher

As noted in the code, this should not be necessary and I don't believe it
has anything to do with this code. I would suspect some lower-level issue
with flipping between different widgets within a container. I need to find a
way to make an isolated reproduction that isn't about this particular
widget. Meanwhile though this works with the refresh().

* Swap current from var to reactive

This solves the explicit refresh issue, but only because the refresh is
implied due to the use of a reactive over a var. As such this sort of
addresses #1979 by ignoring the issue rather than diving into it.

I still suspect that I shouldn't need to do this, and that perhaps there's a
refresh issue when you flip display. So I'll keep #1979 kicking around and
at some point see if I can recreate in isolation.

* Add unit tests for the content switcher

* Add snapshot tests for the ContentSwitcher

* Clarify that an exception can be thrown on a bad ID

* Try and help other Pythons

* Add a pause at the end of the second switcher snapshot test

I'm getting a lot of fails in CI; none of them are actual problems.
Hopefully this will cure it.

* Paaaaaaaaause

More of a test than anything else really. My particular snapshot test is
failing but kinda randomly in each environment each time -- sometimes
Windows, sometimes GNU/Linux, different Python versions.

So... yeah, let's try this and see if it makes it through; otherwise I may
need to rethink this.

* New pause

So it turns out that _ doesn't do anything any more; and instead there's a
"wait:<n>" syntax! So let's give that a try.

* Learning my alphabet...

* Fix a typo in the docs.

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Add missing full stop.

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Add a missing word

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Try a longer wait on the switcher

I'm starting to suspect that this doesn't come down to a timing issue;
especially given that the snapshot report seems to be showing some oddity in
the length of the vertical scrollbar. But... I want to be as sure as
possible so let's double the length of the wait.

Bit a bit of me is starting to wonder if I've somehow managed to create the
perfect storm for scrollbars and you don't always get the same result every
time.

Seems unlikely, but if it's not timing it's that or lots of cosmic rays.

* Test a longer pause on the content switcher test

The idea here being that it takes 200ms for the button to pop again.

* Refresh the snapshots

This time. THIS TIME!

* Experiment: is the issue the same name for two tests?

* Experiment: drop the different source files, try terminal size

Having got over the issue of the button not ending up in the same state,
we're stuck with the scrollbar having different sizes. Having tried other
options let's go with tweaking the terminal size.

* Do a little less work when changing current

Rather than set everything invisible then the new one visible, every time
current is changed, instead just make sure everything is invisible up front
and then just swap the affected children each time.

This does mean that if someone messes with the children under the hood they
may see oddness happening, but less work while being less defensive seems
fair here.

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-09 11:39:30 +00:00
TomJGooding
e95a65fa56
docs(compound example): fix typo (#1984) 2023-03-08 17:42:25 +00:00
Will McGugan
864931e94b
Compound docs (#1952)
* compound example

* update bit switch

* prevent

* no css

* compound widget example

* more diagrams

* more diagrams

* diagrams

* words

* words

* remove sender

* removed priority post

* timer fix

* test fixes

* drop async version of post_message

* extended docs

* fix no app

* Added control properties

* changelog

* changelog

* changelog

* fix for stopping timers

* changelog

* docs update

* last byte example

* new section

* update of byte03

* updae to docs

* Added compound examples

* Rewording

* Use set sender

* don't need this

* hyphens

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* parenthesis

* stack diagram

---------

Co-authored-by: Dave Pearson <davep@davep.org>
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-06 16:56:24 +00:00
Rodrigo Girão Serrão
294213e0a1
Update radio_set_changed.py (#1947)
In the aftermath of #1935 and #1940 this fell through the cracks.
2023-03-06 12:04:22 +00:00
Dave Pearson
623b70d4ac
Add an example of using a RadioSet.Changed message (#1935)
Unlike a few other widgets, the RadioSet is pretty much all about reacting
to the selection result; the question of how you go about it has already
come up and while the message is documented, complete with all properties,
it can't hurt to have an illustrative example of code that uses it.

Here I add an extra RadioSet example that sits with the message in the
reference. This should help the reader better follow how to use it, and also
gives something to link to if someone hasn't got that far into the
documentation yet but is attempting to use the RadioSet.
2023-03-06 10:53:12 +00:00
Will McGugan
373fc95fc1
Drop explicit sender attribute from messages (#1940)
* remove sender

* removed priority post

* timer fix

* test fixes

* drop async version of post_message

* extended docs

* fix no app

* Added control properties

* changelog

* changelog

* changelog

* fix for stopping timers

* changelog

* added aliases to radio and checkbox

* Drop sender from Message init

* drop time

* drop cast

* Added aliases
2023-03-06 10:52:34 +00:00
Dave Pearson
6d0fc0489f
Rework the layout of the checkbox example
Time to start to show off the new compose method.
2023-02-27 09:11:18 +00:00
Dave Pearson
23c0587efb
Rework the layout of the radio button example
Time to start to show off the new compose method.
2023-02-27 09:10:10 +00:00
Dave Pearson
f436489efa
Rework the layout of the radio set example
Time to start to show off the new compose method.
2023-02-27 09:08:40 +00:00
Dave Pearson
e6e46d0825
Merge branch 'main' into toggle-boxen 2023-02-27 08:53:30 +00:00
Will McGugan
9c1f6f7fad Added docs for the new compose method 2023-02-26 10:34:30 +00:00
Will McGugan
63438f170d
Update docs/examples/events/prevent.py
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-02-24 12:02:56 +00:00
Will McGugan
217956bbdf
Update docs/examples/events/prevent.py
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-02-24 12:02:46 +00:00
Dave Pearson
307b1789a1
Give radio button its own example code now
Still within a RadioSet, but this time only the code that uses RadioSet; not
the code that just uses strings.
2023-02-23 16:00:14 +00:00
Dave Pearson
a821b2f8f6
Add width reference documentation for radio buttons
A large part of the code to go with this is to show off a radio set; I feel
it makes sense to use the same code for both bits of documentation given
that a radio button only really makes sense inside a radio set.
2023-02-23 15:14:25 +00:00
Dave Pearson
a3d50d90f6
Revert example code to composing the old way
We've not documented it yet so, until we do...
2023-02-23 15:09:45 +00:00
Dave Pearson
87bd610eec
Swap the checkbox example to the newer compose approach 2023-02-23 14:45:24 +00:00
Will McGugan
da9e28d4d6 Add example 2023-02-23 14:41:44 +00:00
Dave Pearson
01215a1fe8
Tweak the style of the box in the example for checkbox 2023-02-23 14:40:58 +00:00
Dave Pearson
3fd3d272ce
Add the widget reference for Checkbox 2023-02-23 14:26:11 +00:00
Will McGugan
11d10db1ab fast path for scrolling 2023-02-17 10:42:42 +00:00
Will McGugan
0dac83668b
Merge pull request #1791 from Textualize/textual-markdown
Textual markdown
2023-02-15 09:23:19 +00:00
Will McGugan
08c3a7214e No, I repeat, no abbreviations 2023-02-14 17:28:24 +00:00
Will McGugan
71d0017ef9 docs and refactor 2023-02-14 15:22:15 +00:00
darrenburns
bd73b1b007
Merge branch 'main' into datatable-cell-keys 2023-02-13 16:02:37 +00:00
Will McGugan
a37e7fcb2b fix modal example 2023-02-11 15:37:24 +00:00
Darren Burns
f4cd51e5e8
Merge branch 'main' of github.com:Textualize/textual into datatable-cell-keys 2023-02-09 15:55:45 +00:00
Dave Pearson
1956f7f9d7
Rename the switch--switch component class to switch--slider
Following on from #1751: originally Switch was called Checkbox and the
moving part was, for the component class, called a checkbox--switch; after
renaming the widget to Switch that component class ended up being
switch--switch; which wasn't ideal.

We decided to go with it as-is, but I just realised that internally the code
calls it a slider. So this leans into that and I'm renaming the component
class switch--slider. This removes the doubling-up of the name and also
makes the code more consistent.
2023-02-09 15:36:04 +00:00
Dave Pearson
decc1e2f3c
Rename Checkbox to Switch
A new form of Checkbox will be arriving in Textual soon, working in
conjunction with a RadioButton. What was called Checkbox is perhaps a wee
bit heavyweight in terms of visual design, but is a style of widget that
should remain.

With this in mind we're renaming the current Checkbox to Switch. In all
other respects its workings remains the same, only the name has changed.

Things for people to watch out for:

- Imports will need to be updated.
- Queries will need to be updated; special attention will need to be paid to
  any queries that are string-based.
- CSS will need to be changed if any Checkbox styling is happening, or if
  any Checkbox component styles are being used.

See #1725 as the initial motivation and #1746 as the issue for this
particular change.
2023-02-09 11:10:30 +00:00
Darren Burns
20b8782a5d Unit tests for DataTable reverse sort 2023-02-08 12:54:15 +00:00
Rodrigo Girão Serrão
e5e7c08afe Update docs accordingly. 2023-02-08 10:53:51 +00:00
Darren Burns
0721d7fc87 Snapshot test for sorting 2023-02-08 10:39:04 +00:00
Darren Burns
802ea63ddb
Default cell formatter fixes 2023-02-07 15:09:21 +00:00
Will McGugan
fb7fd14262
Merge pull request #1710 from Textualize/line-api-docs
Documented the Line API
2023-02-06 11:42:57 +00:00
Will McGugan
f8577f79d7 review fixes 2023-02-06 11:34:37 +00:00
Will McGugan
fb7c1642bc Checker example 4, docs and diagram 2023-02-04 15:40:36 +01:00
Will McGugan
25b498896d checker 4 and diagram 2023-02-04 11:28:07 +01:00
Will McGugan
a5808db8b8 more docs and diagrams 2023-02-03 19:10:03 +01:00
Will McGugan
2ff278874b docs examples and diagrams 2023-02-03 11:23:14 +01:00
Will McGugan
8ce76f4f89 fix title update 2023-02-01 18:01:34 +01:00
Will McGugan
806c80b8fe simplify 2023-02-01 17:14:53 +01:00
Will McGugan
0a5838d964 checker example 2023-02-01 16:26:55 +01:00
Rodrigo Girão Serrão
828d8d2cf1 Replace Static with Label. 2023-01-31 17:31:36 +00:00
Rodrigo Girão Serrão
c14f635244 Document setting app (sub)title. 2023-01-31 17:31:06 +00:00
Rodrigo Girão Serrão
0f3aff6fb1
Merge pull request #1408 from Textualize/review-styles-reference
Review styles reference
2023-01-10 14:20:11 +00:00
Ofek Lev
9b779c130d
Fix typo 2023-01-10 01:42:16 -05:00
Rodrigo Girão Serrão
d41471034a Fix failing tests. 2023-01-09 16:39:12 +00:00