Commit Graph

79 Commits

Author SHA1 Message Date
Rodrigo Girão Serrão
c13308a360 Add tests for Horizontal/Vertical(Scroll) containers. 2023-03-09 17:39:05 +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
darrenburns
4921a5cb43 Snapshot tests for the CLI preview apps (#1969) 2023-03-07 16:42:21 +00:00
Dave Pearson
b7de48cca3 Border colour percentage (#1954)
* Allow setting an additional alpha on a border

See #1863.

* Update the ChangeLog

* Add snapshot tests for the border alpha value

* Extend the border snapshot tests

While this doesn't test *every* permutation, it covers enough bases that if
something were to change it should catch it.

* Tweak a typo in the border style examples

* Add border transparency percentage to the border docs

* Add a CSS example for using border transparency

* Add Color.multiply_alpha

* Update the CHANGELOG

* Multiply the alpha on a colour rather than replace it

As requested in
https://github.com/Textualize/textual/pull/1954#pullrequestreview-1328170386

(actually required while talking in person with Will, but noted in the
above)

* Multiply the alpha on a border colour rather than replace it

As requested in
https://github.com/Textualize/textual/pull/1954#pullrequestreview-1328170386

(actually requested while talking in person with Will, but noted in the
above)
2023-03-07 14:14:17 +00:00
Will McGugan
41003e356c Fix content width (#1910)
* fix calculation for scrollbars

* added snapshot

* fix for name change

* snapshot

* fix for textual colors

* remove logs

* scrollbar logic

* scroll logic

* remove dead code

* snapshot tests

* scrollbar mechanism

* tidy

* demo tweak

* preset window size

* no need for repaint

* Restore repaint

* wait for idle on pause

* colors tweak

* remove wait for idle

* snapshot

* small sleep

* change stabilizer

* debug tweaks

* remove debug

* remove debug

* snapshot test

* docstring

* changelog

* add pause
2023-03-02 14:39:31 +00:00
Dave Pearson
8c5fb38851 Merge branch 'main' into toggle-boxen 2023-02-27 10:31:06 +00:00
darrenburns
cbe2ab87c6 Datatable labelling rows (#1868)
* Renaming some component classes in DataTable

* Some more renaming of DataTable component classes

* Separate styling for fixed rows/columns from labels

* Highlight fixed rows/cols affected by colour differently

* Tweaking styles for fixed data in DataTable

* Update DataTable snapshots

* Add row label to Row metadata

* Wiring up some labelled row logic behind flags

* Renaming variable in DataTable

* Variable renaming in DataTable

* [no ci] Labelling rows progress

* Add RenderedRow abstraction to DataTable

* Computing label widths

* Use the Column object to represent row label column

* Ability to toggle row labels reactively

* Adjust width calculation for label widths

* Add DataTable.RowLabelSelected

* Posting the RowLabelClick message

* Hovering of row labels applies new style

* Remove a print

* Ensure horizontal scrolling with column cursor accounts for row label column

* Account for possible row labels in cell cursor horizontal scrolling

* Ensure cursor highlighting is correct on row label cells

* Document component class for DataTable label hover

* Test to ensure clicking row label emits correct event

* Add snapshot test for DataTable with fixed rows/cols and row labels

* Using pilot pause instead of wait_for_idle directly

* Update CHANGELOG

* Add a docstring

* Add a note to CHANGELOG.md about RowLabelSelected
2023-02-27 10:29:17 +00:00
Dave Pearson
24ce819867 Add snapshot tests for the toggle button examples 2023-02-23 22:05:47 +00:00
Will McGugan
5686147909 comment 2023-02-22 14:33:23 +00:00
Will McGugan
c63cab728b force pause 2023-02-22 14:08:54 +00:00
Will McGugan
801051b70b garantee order 2023-02-22 13:32:49 +00:00
Will McGugan
d0d50e4981 cache on 3.9 only 2023-02-22 09:49:10 +00:00
Dave Pearson
6ab9a424a2 Merge branch 'main' into promote-disabled 2023-02-15 10:14:21 +00:00
Will McGugan
0dac83668b Merge pull request #1791 from Textualize/textual-markdown
Textual markdown
2023-02-15 09:23:19 +00:00
Dave Pearson
ba9b2e03d9 Merge branch 'main' into promote-disabled 2023-02-15 08:47:20 +00:00
Dave Pearson
b4f8a6b778 Add disabled snapshot test to the general snapshot tests 2023-02-14 15:53:45 +00:00
Will McGugan
a94c725a3b tests and changelog 2023-02-14 15:26:27 +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
c436b57ed5 Merge branch 'main' into checkbox-switch 2023-02-09 13:57:15 +00:00
Will McGugan
3a9c052d20 Added snapshot 2023-02-09 11:49:11 +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
0721d7fc87 Snapshot test for sorting 2023-02-08 10:39:04 +00:00
Rodrigo Girão Serrão
40fde8cfb9 Merge pull request #1610 from Textualize/fix-1607
Fix #1607 to allow programmatic style changes
2023-01-31 15:13:24 +00:00
Will McGugan
be5a67e903 fix auto width glitch 2023-01-31 12:13:25 +01:00
Will McGugan
71a0a6676f docstring [skip ci] 2023-01-30 19:02:35 +01:00
Will McGugan
4aa988347f add tests 2023-01-30 18:59:23 +01:00
Rodrigo Girão Serrão
b023d4e02e Improve tests. 2023-01-30 12:34:35 +00:00
Will McGugan
41be84b1a5 docstring 2023-01-26 16:01:48 +01:00
Will McGugan
2b3d966410 moar pauses 2023-01-23 12:31:18 +01:00
Darren Burns
36bf162847 Snapshot tests for column and row cursors in DataTable 2023-01-17 14:17:25 +00:00
Darren Burns
b4f2da025a Add pause after datatable snapshot test 2023-01-16 16:40:01 +00:00
Rodrigo Girão Serrão
dd478dd249 Make list_view snapshot test pass more reliably 2023-01-12 15:00:56 +00:00
Rodrigo Girão Serrão
e5375d0a2f Reset color cycle before tests.
We need to reset the color cycle for placeholders before each CSS property test because we need to ensure consistent colouring of the placeholders as tests are added/removed/reordered.
2023-01-09 16:26:33 +00:00
Will McGugan
91e23ff34c more pauses for demo? 2022-12-30 17:31:36 +00:00
Will McGugan
97627107cf add pause 2022-12-30 15:01:57 +00:00
Will McGugan
93716e714b Merge branch 'main' into nested-height-fix 2022-12-20 11:14:45 +00:00
Will McGugan
b265b855cd insert pause 2022-12-19 13:39:03 +00:00
Will McGugan
32b7308ac8 fox for nested heights 2022-12-19 12:54:06 +00:00
Will McGugan
002cbab0d5 add pause to action 2022-12-19 11:26:42 +00:00
Will McGugan
053b7f38e1 snapshot tweak 2022-12-19 10:27:29 +00:00
Will McGugan
cebeafbb8b Merge branch 'main' into list-view 2022-12-09 10:09:07 +00:00
Will McGugan
1f64127235 snapshot 2022-12-08 16:51:31 +00:00
Will McGugan
c405a3baea added demo to snapshots 2022-12-08 11:11:48 +00:00
Will McGugan
bec01bba91 fix for auto width and relative dimensions 2022-12-08 11:06:35 +00:00
Will McGugan
795265bc45 Merge pull request #1229 from Textualize/placeholder
Add Placeholder widget
2022-12-07 16:56:34 +01:00
Will McGugan
23c2c3edd3 fix for visiblity 2022-12-07 14:41:30 +00:00
Rodrigo Girão Serrão
ba5ec6b34b Merge branch 'main' of https://github.com/Textualize/Textual into placeholder 2022-12-05 15:08:01 +00:00
Will McGugan
962b7d64b4 pause 2022-12-04 17:25:09 +07:00
Will McGugan
0a8b001c62 fix for layer ordering 2022-12-04 17:17:27 +07:00
Darren Burns
eb8c078306 Merge branch 'main' of github.com:willmcgugan/textual into list-view 2022-11-23 11:03:40 +00:00