-
-
Couldn't load subscription status.
- Fork 1k
Initial pull of 5x5 into the Textual examples directory #963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
*evil grin*
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.
Rather than repeat the same code over a number of lines, use a loop.
Also settle focus on the middle cell at the start of a game -- this is the start of adding keyboard navigation.
Uses arrow keys or WASD. Also note moving the dark mode toggle off 'd' and onto 'D'.
I'm going to repurpos.e it
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Just a few requests.
Once that's in, I might have a go at the stylesheet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change your import of Final to something like this?
import sys
if sys.version_info >= (3, 8):
from typing import Final
else:
from typing_extensions import FinalBecause 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 Textualize#963 (comment)
See Textualize#963 (comment) 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.
I think this is in a good enough state to start to pull it in now. It has keyboard navigation, mouse navigation, a simple help screen, a simple win state display, etc. It demonstrates not using a default screen, etc. Colour needs some work, but I think the core implementation is pretty sound now.
Tweaks to make it more Textually idiomatic are welcome -- this is obviously written by someone who is still getting to know the framework.