Commit Graph

630 Commits

Author SHA1 Message Date
Dave Pearson
e75f784b2c Add a test for a screen binding movement, wrapping a focusable widget
This is the heart of the issue introduced by
b48a1402b8
and which is being investigated in
https://github.com/Textualize/textual/issues/1343 -- the child widget can be
focused, but (as far as the author of the code is concerned) it has no
bindings. Bindings for movement-oriented keys exist on the screen which
composes up the widget into it. Up until 0.5.0 this worked just fine. As of
0.6.0, because binding inheritance was introduced, the bindings for movement
that live at the `Widget` level cause the widget that has no bindings to
appear to have bindings.

While this can potentially be worked around with the use of
inherit_bindings, this isn't a very satisfying solution and also breaks the
rule of least astonishment.

This test is going to be key to all of this. This is the test that should be
made to work without breaking any of the other currently-passing tests.
2022-12-13 10:12:16 +00:00
Dave Pearson
06e45c709e Add an alpha binding and key press to the focused widget test
This is going to become important in the next test I'm intending to add, so
it feels sensible to mirror the intended addition here too.
2022-12-13 10:02:44 +00:00
Dave Pearson
4955a28ab1 Keep black happy (again)
Need to sort out the pre-commit hooks for this machine
2022-12-13 09:48:09 +00:00
Dave Pearson
c52ea0bdf2 Add a test for a focused child widget with its own bindings 2022-12-13 09:46:27 +00:00
Dave Pearson
b48acc0bd5 Update the movement binding tests to use all movement keys
Rather than just test a single specific movement key (in this case "up"), go
with all the affected keys. The cost to doing so is zero and it means we get
a full coverage of testing for all the keys that have become a problem with
0.6.0.
2022-12-13 08:27:22 +00:00
Dave Pearson
751042f9d7 Add a test for actions being fired from bound keys
Do this with a focus on detecting a bound alpha key, and a bound movement key
2022-12-12 21:53:23 +00:00
Dave Pearson
f32937641a Add binding inheritance tests for Static widgets 2022-12-12 21:04:56 +00:00
Dave Pearson
6b77e73558 Start unit tests for live key bindings plus inheriting
Up until now there doesn't seem to have been any unit tests aimed squarely
at setting up bindings, as part of a running application, which are only
about testing the bindings. As such there was no way of slotting in tests
for how inheritance of bindings works.

This starts that process with a view to testing how inheriting
likely *should* work.

See #1343 for some background to this.
2022-12-12 20:49:19 +00:00
Will McGugan
f51234498a tweaked placeholder 2022-12-10 18:00:43 +00:00
Will McGugan
c76d616521 updated snapshot 2022-12-10 17:54:57 +00:00
Will McGugan
47ecb4b7b0 Test 2022-12-10 12:00:12 +00:00
Will McGugan
5af3470728 update snapshot 2022-12-10 10:44:02 +00:00
Rodrigo Girão Serrão
311229fe4b Merge branch 'main' into fix-1335 2022-12-09 16:04:42 +00:00
Rodrigo Girão Serrão
351d157ccf Add test for get_default_css. 2022-12-09 15:58:29 +00:00
Will McGugan
24a182c104 fix snapshot 2022-12-09 10:22:26 +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
c44ae8b93e snapshot fix 2022-12-08 11:23:56 +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
f1500f84bb Merge branch 'main' into fix-1309 2022-12-07 17:33:03 +01:00
Will McGugan
795265bc45 Merge pull request #1229 from Textualize/placeholder
Add Placeholder widget
2022-12-07 16:56:34 +01:00
Will McGugan
a25a60efbf remove html test 2022-12-07 15:01:50 +00: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
Dave Pearson
cd4b421b74 Update snapshots to take into account new default Label width 2022-12-05 07:40:28 +00:00
Will McGugan
962b7d64b4 pause 2022-12-04 17:25:09 +07:00
Will McGugan
eab69a7739 snapshots 2022-12-04 17:18:42 +07:00
Will McGugan
0a8b001c62 fix for layer ordering 2022-12-04 17:17:27 +07:00
Rodrigo Girão Serrão
40fd3e8f78 Add box model test for empty container. 2022-12-03 14:26:42 +00:00
Rodrigo Girão Serrão
1def555a76 Add tests for dimensions of empty containers. 2022-12-02 15:43:24 +00:00
Darren Burns
f0c4023c47 Merge branch 'main' of github.com:Textualize/textual into list-view 2022-11-30 12:15:08 +00:00
Rodrigo Girão Serrão
9654748dd7 Update example and test files. 2022-11-25 18:23:24 +00:00
Dave Pearson
ab760dbe80 Add a test for numbers within a type query name
Add a failing test due to #1253.
2022-11-24 21:04:36 +00:00
Darren Burns
01cbd7bdd0 Update snapshot for ListView - keys no longer shown in footer 2022-11-23 11:08:44 +00:00
Darren Burns
eb8c078306 Merge branch 'main' of github.com:willmcgugan/textual into list-view 2022-11-23 11:03:40 +00:00
Darren Burns
afafc054f5 Update snapshot 2022-11-21 15:31:58 +00:00
Darren Burns
b21eb0659b Adding list view snapshot test with key presses 2022-11-21 15:15:55 +00:00
Will McGugan
f7dade5a26 new tree control 2022-11-20 15:42:35 +00:00
darrenburns
e968ca0e50 Various tests for reactivity (#1223) 2022-11-18 19:40:30 +00:00
Rodrigo Girão Serrão
0b30c3a1d5 Fix snapshot test by resetting colour cycle. 2022-11-18 15:54:32 +00:00
Rodrigo Girão Serrão
54b85399e7 Merge branch 'main' into placeholder 2022-11-18 15:21:40 +00:00
Rodrigo Girão Serrão
a87c9ca916 Add tests for placeholder widget. 2022-11-18 15:14:56 +00:00
darrenburns
36664ef7ae Sensible default key displays + allow users to override key displays at the App level (#1213)
* Get rid of string split key display

* Include screen level bindings when no widget is focused

* Add default key display mappings

* Allow user to customise key display at app level

* Better docstring

* Update CHANGELOG.md
2022-11-18 14:05:45 +00:00
darrenburns
e32e094b92 Support callables in App.SCREENS (#1185)
* Support Type[Screen] in App.SCREENS (lazy screens)

* Update CHANGELOG

* Remove redundant isinstance
2022-11-16 15:47:48 +00:00
darrenburns
df37a9b90a Add get_child_by_id and get_widget_by_id (#1146)
* Add get_child_by_id and get_widget_by_id

* Remove redundant code

* Add unit tests for app-level get_child_by_id and get_widget_by_id

* Remove redundant test fixture injection

* Update CHANGELOG

* Enforce uniqueness of ID amongst widget children

* Enforce unique widget IDs amongst widgets mounted together

* Update CHANGELOG.md

* Ensuring unique IDs in a more logical place

* Add docstring to NodeList._get_by_id

* Dont use duplicate IDs in tests, dont mount 2000 widgets

* Mounting less widgets in a unit test

* Reword error message

* Use lower-level depth first search in get_widget_by_id to break out early
2022-11-16 15:29:59 +00:00
darrenburns
a465f5c236 Horizontal width auto (#1155)
* Improvements to width:auto HorizontalLayout

* Fix HorizontalLayout.get_content_width

* Horizontal width auto improvement

* Removing some printxz

* Update snapshot for horizontal layout width auto dock
2022-11-16 14:49:52 +00:00
Will McGugan
e79cad6cb5 Merge pull request #1173 from davep/move-child
Add Widget.move_child
2022-11-15 13:46:22 +00:00
Dave Pearson
af1168b4ee Don't take transparent to imply not visible
This seeks to address #1175, where a containing widget with a transparent
background, but with a border, won't show the border. It seems that at the
heart of the Compositor it's taking `is_transparent` (of the widget) as one
of the indicators that mean that it won't be visible. This wouldn't normally
be the case, in that a widget could be transparent (in the background) but
could have visible content.

Note that some snapshot tests failed with this change, but no material
difference was found in those failing snapshot tests.
2022-11-15 11:59:01 +00:00
Dave Pearson
48e5f5e026 Add Widget.move_child
Adds a method to Widget that allows moving a child of that widget within its
list of children. Options are to move before or after a specific location,
or a sibling widget.

Seeks to implement #1121.
2022-11-14 12:22:24 +00:00