Commit Graph

1208 Commits

Author SHA1 Message Date
Dave Pearson
b44983e8d4 Add an add_options method to the OptionList
In doing so, pretty much make the add_option code into the add_options code,
and then just have add_option call add_options.

See #2507.
2023-05-07 17:56:02 +01:00
Dave Pearson
6139c95f3a Test that the event aliases are actually the same reference
I thought I thought I wanted what I thought but now I think about it I think
I thought wrong and now I think better.
2023-05-04 16:43:20 +01:00
Dave Pearson
8b36d29e74 Add a test for a radio set getting focus when a button gets clicked 2023-05-04 16:22:39 +01:00
Dave Pearson
19f4f64d96 Add tests for selection navigation in a radioset with no buttons pressed 2023-05-04 15:39:33 +01:00
Dave Pearson
e7d3b94334 Test that radioset wraps around when going off the bottom 2023-05-04 15:25:33 +01:00
Dave Pearson
b1443c0162 Test that radioset wraps around when going off the top 2023-05-04 15:22:30 +01:00
Dave Pearson
2113f415a0 Add a test that toggling a pressed radio button has no effect 2023-05-04 15:17:52 +01:00
Dave Pearson
b7cdbb0baa Test to ensure that Changed.control is Control.checkbox 2023-05-04 15:12:15 +01:00
Dave Pearson
0b4d7fb091 Test to ensure that Changed.control is Control.radio_button 2023-05-04 15:10:45 +01:00
Rodrigo Girão Serrão
3728555fbd Scroll cursor into view. (#2464)
* Scroll cursor into view.

Related issues: #2459.

* Add regression test.

* Update changelog.
2023-05-03 13:57:04 +01:00
Will McGugan
41dbc66b23 optimize focus (#2460)
* optimize focus

* immediate call

* update previews

* snapshot
2023-05-03 11:48:56 +01:00
Will McGugan
91a9d570a4 On decorator (#2453)
* Add on decorator

* decorator code

* docs for on decorator

* Examples

* test errors

* simplify listing

* words

* changelog

* Update docs/guide/events.md

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

* Update docs/guide/events.md

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

* Update docs/examples/events/on_decorator.css

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

* Update docs/guide/events.md

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

* rewording

* comment

* clarification

* Added note

---------

Co-authored-by: Dave Pearson <davep@davep.org>
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-05-02 16:17:40 +01:00
Dave Pearson
2ad3903d43 Remove the bytewise diffing of failed snapshots
In doing so this removes the file similarity value, and as such the key that
the failure report was sorted on. This was done because, given how many
snapshot tests we have now, if lots failed, it would take a long time (often
many minutes) to compile the report.

The report is now sorted on the test name.

Now, no matter how many snapshots fail, the report should be produced pretty
much instantly.
2023-05-02 13:47:18 +01:00
Dave Pearson
27ca4969a8 Add tests for styles that have "sub-styles" and !important
This is a series of tests for checking styles that have sub-styles, or
sub-parts, or whatever the correct name would be; the testing being that if
!important is applied to the whole, that it works.

Starting with #2420 it became apparent that this didn't work as intended,
and once that work started it became obvious that it affected more than just
border.

So these tests test all of the styles that can be specified as a single
whole, or as a set of parts (sides, directions, etc).
2023-05-02 09:36:08 +01:00
Will McGugan
83b1fcc102 raise attribute error (#2443)
* raise attribute error

* fix compute defaults
2023-05-01 16:57:40 +01:00
Will McGugan
20a1612361 Invalid pseudo selectors (#2445)
* token error

* error on bad pseudo selectors
2023-05-01 16:22:35 +01:00
Dave Pearson
54db445dd7 Change private watcher support call public and private if available
See https://github.com/Textualize/textual/pull/2442#issuecomment-1529512891

This changes the original PR so that, rather than calling a private watcher
instead of a public, as originally issued, we now call public and private,
if they're both there.

If they are both there private is called first.
2023-05-01 10:28:55 +01:00
Dave Pearson
847fd6e69e Add support for private watch methods
This change allows for private watch methods. By convention they start with
an underscore. If a reactive or var has a private watch method, it will be
used in preference to a public watch method.

With this change it becomes easier to have a private reactive/var whose
watcher is also private. For example:

    _counter = var(0)
    """This is a private counter, it won't appear in the docs."

    ...

    def _watch__counter(self) -> None:
        """Watch _counter, but don't appear in the docs either."
        ...

See #2382.
2023-05-01 10:01:50 +01:00
Dave Pearson
02ed90c633 Add TreeNode.tree
Currently, in the various TreeNode messages, and the handlers you'd write to
handle them, there's no way to easily know *which* tree sent the message and
so which tree the node belongs to.

This commit adds public access to the tree reference to the nodes, so that
in an event handler the developer can check the tree involved in the event.

See #2413.
2023-04-28 10:23:38 +01:00
Will McGugan
124c45e68c Bump0220 (#2405)
* Version bump

* upate version

* fix domain name

* wrong project

* skip on Windows

* disable demo snapshot

* 37 fix
2023-04-27 15:01:46 +01:00
Will McGugan
dd70a7a2dc fix for min and max with fr unints (#2390)
* fix for min and max with fr unints

* snapshit

* forgot snapshit tests

* fix resolve

* added unit tests

* Windoze fix
2023-04-27 13:35:16 +01:00
Rodrigo Girão Serrão
4148b1d450 Implement a Progress Bar widget. (#2333)
* First prototype of PB.

* Repurpose UnderlineBar.

* Factor out 'Bar' widget.

* Revert "Factor out 'Bar' widget."

This reverts commit 0bb4871adf.

* Add Bar widget.

* Cap progress at 100%.

* Add skeleton for the ETA label.

[skip ci]

* Add ETA display.

* Improve docstrings.

* Directly compute percentage.

* Watch percentage changes directly.

[skip ci]

* Documentation.

* Make reactive percentage private.

Instead, we create a public read-only percentage property.

* Update griffe to fix documentation issue.

Related issues: #1572, https://github.com/mkdocstrings/griffe/issues/128.
Related PRs: https://github.com/mkdocstrings/griffe/pull/135.

* Add example and docs.

* Address review feedback.

[skip ci]

* More documentation.

* Add tests.

* Changelog.

* More tests.

* Fix/fake tests.

* Final tweaks.
2023-04-26 15:25:39 +01:00
Dave Pearson
7a536c790c Demo snapshot test back up to a 250 wait
Waiting 100 resulted in a fail, so let's bump back up again.
2023-04-25 15:49:43 +01:00
Dave Pearson
db45287646 Lower the wait for the demo snapshot test
250 worked; so let's try it lower.
2023-04-25 15:41:02 +01:00
Dave Pearson
88926a4bb8 Force a wee wait when testing the demo
This keeps randomly failing in Windows in CI; multiple subsequent runs gets
it going in the end, normally one further fail at a time. So let's throw a
wee wait on the end and see if that helps.
2023-04-25 15:27:43 +01:00
Dave Pearson
c45f9358ee Change RadioSet so it's less a container of widgets and more a widget
Initially we went with a RadioSet being a simple container of RadioButtons,
with the user navigating the RadioButtons like you would any other set of
widgets. This was fine but it became pretty clear pretty quickly that having
to tab through a non-trivial collection of buttons in a set to get to the
next widget wasn't ideal.

This commit, satisfying #2368, takes over the navigation of the buttons
within the container, makes the container itself a focusable widget, and
sets up some new bindings to allow a more natural and efficient interaction
with the set.
2023-04-25 15:00:44 +01:00
Dave Pearson
a6a373161f Add some unit testing of the new navigation 2023-04-25 12:06:46 +01:00
Dave Pearson
e16493bf81 Update the snapshot tests
This is necessary now that a focused RadioSet has acquired a border colour
similar to that if a focused Input.
2023-04-25 11:27:23 +01:00
Dave Pearson
ca94c5eed0 Merge branch 'main' into no-container-scroll 2023-04-24 11:35:47 +01:00
Rodrigo Girão Serrão
e5033d7d23 Remove hanging lines from docstrings. (#2349)
* Remove hanging lines from docstrings.

Deleted hanging blank lines at the end of docstrings.

Regex pattern:
 - find `\n\n( *)"""`
 - replace with `\n$1"""`
2023-04-24 11:21:38 +01:00
Dave Pearson
b896e9d7f9 Update tests to handle scroll changes to Container
See #2361.
2023-04-24 11:10:37 +01:00
Will McGugan
80f4c12e76 Fix scroll flicker (#2358)
* fix scroll flicker

* fix scroll flicker

* remove event

* do not delay scroll

* remove comment

* test fix

* remove commented code

* comment

* increase pause on click

* changelog [skip ci]

* wait on resume

* remove note [skip ci]
2023-04-24 09:33:15 +01:00
Dave Pearson
75543fbd4c Merge branch 'main' into bug/2352/tabbed-content-active 2023-04-22 10:28:02 +01:00
Will McGugan
a2633ca31e fix text opacity (#2356) 2023-04-22 08:50:14 +01:00
Dave Pearson
a351d620b2 Add some pauses to the UI-baed tabbed content tests
This particular test seems rather flakey in GitHub's actions. In most cases
passing, with the odd fail here and there (normally when unrelated changed
are made -- I've had this fail when docs have been changed; zero code
changes!)

So, on the off chance that a little extra pause will help...
2023-04-22 08:42:38 +01:00
Dave Pearson
c022d9de2f Fix TabbedContent.active not changing actual content
Ensures that the actual content gets changed when TabbedContent.active is
updated via code. Also adds more testing for TabbedContent.

See #2352 for details.
2023-04-22 08:28:12 +01:00
Will McGugan
cab4925eaa New CLI runner (#2338)
* New CLI runner

* runner functionality

* Add port

* use env for port

* changelog

* test fix

* flush

* remove constant

* comment

* tidy docs

* docstrings

* punctuation

* docstring

* fix test

* snapshot

* Update src/textual/cli/cli.py

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

* guard against bad imports

* guard againsts screenshot

* always print return

* docstrings

* docstrings

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-04-20 17:09:39 +01:00
Dave Pearson
1c5909eb23 Update the binding inheritance tests for the new moment bindings approach
Now that navigation bindings don't pollute the whole widget hierarchy any
more some of these tests can be tidied up.
2023-04-20 10:04:32 +01:00
Will McGugan
81882fdf7d implement dim fix (#2326)
* implement dim fix

* docstrings

* foreground fix

* cached filters

* cache default

* fix for filter tests

* docstring

* optimization

* Update src/textual/filter.py

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

* Update src/textual/constants.py

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-04-19 13:24:31 +01:00
Will McGugan
db1b784606 dim filter (#2323)
* dim filter

* optimization

* Remove test code

* move functions out of filter

* docstring

* move function to module scope

* docstring

* docstrings
2023-04-19 09:31:59 +01:00
Rodrigo Girão Serrão
66a644845b Prevent reactive-watcher loop in Tabs / TabbedContent. (#2305)
* Add regression test for #2229.

* Fix potential reactive-watch loop.

* Simplify regression test.

Labels are cheaper to use and the final visual result of the test won't depend on the directory it runs from.

* Simplify solution.

Turns out I didn't need a descriptor. :(

* Fail on empty tab.
2023-04-18 11:48:33 +01:00
Rodrigo Girão Serrão
3a7cf08ef2 Make scrollable containers focusable. (#2317)
* Make scrollable containers focusable.

Related issues: #2270.
2023-04-18 11:44:32 +01:00
darrenburns
496f8b4524 Updating styles on demand instead of on_idle (#2304)
* Updating styles on demand instead of on_idle

* Tidy up update_styles

* Fix LRU cache tests

* Remove some debugging code

* Adding test for pseudoclass style update

* Update changelog
2023-04-18 11:36:00 +01:00
Will McGugan
0509cf8948 Border style (#2292)
* border styles

* docs for border styles

* fix tests

* tests

* tests and docs

* changelog

* implement auto

* style information fix
2023-04-16 12:31:39 +01:00
darrenburns
898de5a69c Fix for empty ListView bindings not firing (#2281)
* Fix bindings not firing when ListView is empty

* Regression test for empty ListView bindings not working

* Update changelog
2023-04-13 15:32:56 +01:00
Rodrigo Girão Serrão
bb2c31ba35 Add --port option to textual console. (#2258)
* Add --port option to textual console.

* Changelog.

* Address review feedback.

* Mark unpredictable test as xfail.

This test gets an xfail mark until #2254 is open.

* Make DEVTOOLS_PORT a constant.

Related review: https://github.com/Textualize/textual/pull/2258\#discussion_r1165210395

* Factor logic into function.

Related review: https://github.com/Textualize/textual/pull/2258\#discussion_r1165298259

* Remove dead import.
2023-04-13 11:57:35 +01:00
Rodrigo Girão Serrão
663b09736e Scroll to center when tab is clicked.
Related comment: https://github.com/Textualize/textual/issues/2256#issuecomment-1505551728
2023-04-12 22:25:37 +01:00
darrenburns
6369c37907 Ensure styles applied in correct order in DataTable (#2272)
* Ensure styles applied in correct order in DataTable

* Add snapshot regression test for datatable style ordering

* Update CHANGELOG
2023-04-12 14:45:24 +01:00
darrenburns
f95e30870b Tabbed content activated message (#2260)
* Add a message for the tabbed content activated

* Add a docstring

* Testing tabbed content activated message

* Update changelog

* Add reference to the docs about TabbedContent.TabActivated
2023-04-12 10:55:14 +01:00
darrenburns
6352ceb61b Datatable remove row (#2253)
* Checking in remove_row progress

* Ensuring structures updated correctly when row deleted

* Clamping index

* Failed attempt

* Removing rows

* Update a type hint in DataTable

* Remove some code that wasnt required

* Use index syntax instead of get

* Add DataTable remove row test

* Snapshot tests for removing rows

* Add a docstring for DataTable.remove_row method

* Update changelog regarding DataTable.remove_row

* Add check_idle call to remove_row
2023-04-11 18:48:58 +01:00