Commit Graph

2683 Commits

Author SHA1 Message Date
Dave Pearson
491a315aed Switch the dark mode toggle to Ctrl+D
It was on D (as in uppercase D, or shift-d), but I feel this was going to be
confusing given that there is still this slight mixup with the display of
letters in the footer, and what was bound, etc.

So... make it obvious what to press.

Remember, 'd' can't be used because it's a movement key in this game.
2022-10-20 20:42:48 +01:00
Dave Pearson
8e1dcbd2e1 Add a wee bit of animation 2022-10-20 15:55:49 +01:00
Dave Pearson
e0cea53d2f Sweep up some on->filled naming changes 2022-10-20 14:49:30 +01:00
Dave Pearson
db976348cc Swap the docstrings away from Sphinx style to Google style
See https://github.com/Textualize/textual/pull/963#discussion_r1000547282
2022-10-20 14:46:18 +01:00
Dave Pearson
615a1997b9 Drop using __file__ to work out the name of the CSS file
See https://github.com/Textualize/textual/pull/963#discussion_r1000546514

Personally I prefer the approach I was using in that it's one less bit of
hard-coded metadata. On the other hand I can appreciate that reducing the
number of possibly-confusing things in an example plays better with people
who may be both new to Textual *and* to Python.
2022-10-20 14:26:28 +01:00
Dave Pearson
b19144abfe Rename "on" things to "filled" things
Because Textual uses on_ for event handlers there was the danger of a name
clash; so to keep things as clear as possible this renames anything to do
with "on" (method names, properties, style classes) so that it talks about
"filled" instead.

See https://github.com/Textualize/textual/pull/963#discussion_r1000544563
2022-10-20 14:11:00 +01:00
Dave Pearson
3e9b30ee2e Handle importing of Final for Python 3.7
See https://github.com/Textualize/textual/pull/963#pullrequestreview-1149139158
2022-10-20 14:04:14 +01:00
Dave Pearson
685f13cfcd Drop the app namespace from some binding actions
It had been suggested to me that these would be needed, but in testing here
I'm not seeing that. So, until I find out otherwise, let's simplify things
and drop that.
2022-10-20 08:43:57 +01:00
Dave Pearson
c629826940 Be nice to the vi(m) crowd 2022-10-20 08:42:38 +01:00
Dave Pearson
4ab660a02a Drop 'h' as a help key01
I'm going to repurpos.e it
2022-10-20 08:37:51 +01:00
Dave Pearson
b3d8ebb2f4 Simplify the tests for a focused game cell 2022-10-19 21:28:50 +01:00
Dave Pearson
59fb6f1ec5 Declutter the status line 2022-10-19 21:23:17 +01:00
Dave Pearson
aa4e4fe2cc Move all the new game logic into the new game action 2022-10-19 21:18:21 +01:00
Dave Pearson
be997409e0 Add keyboard navigation
Uses arrow keys or WASD.

Also note moving the dark mode toggle off 'd' and onto 'D'.
2022-10-19 21:13:41 +01:00
Dave Pearson
851a759e67 Add a central method for getting a cell
Also settle focus on the middle cell at the start of a game -- this is the
start of adding keyboard navigation.
2022-10-19 20:50:19 +01:00
Dave Pearson
eb11984442 Simplify toggle_cells
Rather than repeat the same code over a number of lines, use a loop.
2022-10-19 20:42:25 +01:00
Dave Pearson
056fb70e2a Stop overloading the cell IDs as cargo/data
Originally I was doing everything in the DOM, using just the primitive
widgets. Given that I recently created an actual GameCell widget (which
simply inherits from a Button, but still...) it makes sense to now have
row/col properties as part of that.
2022-10-19 20:16:28 +01:00
Dave Pearson
41bf93abf4 Correct binding to the escape key 2022-10-19 20:10:08 +01:00
Dave Pearson
3fcb00da81 Merge branch 'css' into 5x5 2022-10-19 20:08:45 +01:00
Will McGugan
b18842b46b Merge pull request #962 from Textualize/binding-tuple-fix
Fix bindings as tuples
2022-10-19 17:23:51 +01:00
Dave Pearson
06d1865acc Add 5x5 as an example
*evil grin*
2022-10-19 16:47:25 +01:00
Darren Burns
f28cfec06e Fix bindings as tuples 2022-10-19 16:41:29 +01:00
Will McGugan
48d59bb4fe Merge pull request #961 from davep/bug/939/loss-of-focus-tidy-up
Post-PR #954 tidy up
2022-10-19 16:15:03 +01:00
Dave Pearson
76e9654535 Merge pull request #958 from davep/toll-free
Review the use of the bell in various examples and documentation files
2022-10-19 15:56:21 +01:00
Dave Pearson
7bbfd8ff87 Stop casting walk_children to a list
As of
b56fb018f1
it now returns a list so the cast isn't needed any more.
2022-10-19 15:45:18 +01:00
darrenburns
3e46f5dbdd Populate character on simulated key presses (#960)
* Populate character on simulated key presses

* Undo example
2022-10-19 15:42:54 +01:00
Dave Pearson
2e5e58e599 Don't check that a focusable widget can be focused
As per https://github.com/Textualize/textual/pull/954#discussion_r999501580

Good catch!
2022-10-19 15:42:11 +01:00
Dave Pearson
84e514e9e6 Merge pull request #954 from davep/bug/939/loss-of-focus-take-2
Try and better settle focus after a focused widget is removed (redux)
2022-10-19 15:35:23 +01:00
Dave Pearson
d4859495c6 Merge pull request #952 from davep/css-walk-children-listify
Modify DOMNode.walk_children to return a list
2022-10-19 15:33:45 +01:00
Dave Pearson
d22353d2ec Correct the description of what the button example does
Originally it was partially correct in that it did sound the bell, but it
also then exited the application and printed the details of the button --
the text didn't mention the latter aspect. This corrects that and removes
mention of the bell sound because we've now removed that.
2022-10-19 15:28:15 +01:00
Dave Pearson
836a4e5291 Correct the file included for the second key example
Not an issue with removing the bell, actually a pre-existing mistake in the
docs. The wrong file was being included.
2022-10-19 15:24:44 +01:00
Dave Pearson
f648457c1e action03 doesn't ring the bell on button press any more 2022-10-19 15:21:22 +01:00
Dave Pearson
6f93568f77 Remove the bell from the borders Textual CLI command 2022-10-19 15:19:41 +01:00
Dave Pearson
c4f920be67 Remove the bell from the Button documentation example 2022-10-19 15:15:53 +01:00
Dave Pearson
e8bb084538 Remove intro02.py
It doesn't appear to be referenced anywhere in the docs.
2022-10-19 15:12:54 +01:00
Dave Pearson
bd0e1c01b1 Remove intro01.py
It doesn't appear to be referenced anywhere in the docs.
2022-10-19 15:12:11 +01:00
Dave Pearson
f8bda04d90 Remove the on_space from key01 in the docs
While in this part of the docs we do want to keep the bell (see key02), it
was an error in the code that it included this event in key01. Removing it
from here because adding this bit of code for key02 is a key (no pun) part
of the docs.
2022-10-19 15:05:18 +01:00
Will McGugan
46a885cea7 Merge pull request #957 from Textualize/screens-dark
Fix variables in Screens, remove dark reactive from Screen
2022-10-19 15:01:43 +01:00
Dave Pearson
ce0c6c49a2 Remove the bell from the actions05 documentation example 2022-10-19 14:59:59 +01:00
Dave Pearson
f76e472096 Remove the bell from the actions04 documentation example 2022-10-19 14:57:50 +01:00
Dave Pearson
aa8580bee7 Remove the bell from the actions03 documentation example 2022-10-19 14:54:57 +01:00
Dave Pearson
5c5ca3316f Remove the bell from the actions02 documentation example 2022-10-19 14:43:37 +01:00
Dave Pearson
f5ce603d43 Remove the bell from the actions01 documentation example 2022-10-19 14:41:13 +01:00
Dave Pearson
ae54db4f2a Remove the bell from the calculator
Don't ping the terminal bell on every key-press. This might be okay on some
systems, on others (we're looking at you Windows) it's a wee bit
distracting.

See #955.
2022-10-19 14:21:19 +01:00
Darren Burns
d0cfd1a000 Fix variables in Screens, remove dark reactive from Screen 2022-10-19 14:16:13 +01:00
Dave Pearson
11ddcdd771 Better settle focus when removing a focused widget
Addresses the issue raised in #939. Here I rework Screen._reset_focus so
that, rather than deal with siblings, it deals with the focus chain. It now
also optionally takes a list of DOMNodes to avoid and will, as that
suggests, avoid them when looking for somewhere to move focus to.

As a preference the new version of this will seek to settle focus on the
nearest (in the chain) *previous* non-excluded DOMNode.

NOTE: Currently the return value of Widget.walk_children is cast to a list
to ensure that it doesn't get consumed (as of the time of commit, it's still
qan iterable). Once https://github.com/Textualize/textual/pull/952 has been
accepted I'll change this (remove the cast).
2022-10-19 12:55:43 +01:00
Dave Pearson
4a531dca6b Rename buttons in removal tester
This makes it easier for me to see which widget is which in the focus chain,
etc, when logging.
2022-10-19 12:55:04 +01:00
Dave Pearson
78bb052ac7 Add sandbox code for testing work on #939 2022-10-19 10:45:23 +01:00
Dave Pearson
728d1a5454 Don't remove a widget from display before actual removal
This change ensures that, for example, the widget remains in the
Screen.focus_chain so that it's easier to handle passing off focus on
removal.

To help address #939.
2022-10-19 10:44:44 +01:00
Dave Pearson
b56fb018f1 Modify DOMNode.walk_children to return a list
Originally it returned an iterable, building that up from a list anyway. In
local discussion it's been decided that it makes more sense to simply return
the list. There's no obvious advantage to doing it a different way.
2022-10-19 10:02:55 +01:00