Skip to content

Commit c6125b1

Browse files
committed
2022-12-08 DevLog from davep
1 parent b9cef55 commit c6125b1

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed
287 KB
Loading
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
draft: false
3+
date: 2022-12-08
4+
categories:
5+
- DevLog
6+
authors:
7+
- davep
8+
---
9+
10+
# Be the Keymaster!
11+
12+
## That didn't go to plan
13+
14+
So... yeah... the blog. When I wrote [my previous (and first)
15+
post](https://textual.textualize.io/blog/2022/11/26/on-dog-food-the-original-metaverse-and-not-being-bored/)
16+
I had wanted to try and do a post towards the end of each week, highlighting
17+
what I'd done on the "dogfooding" front. Life kinda had other plans. Not in
18+
a terrible way, but it turns out that getting both flu and Covid jabs (AKA
19+
"jags" as they tend to say in my adopted home) on the same day doesn't
20+
really agree with me too well.
21+
22+
I *have* been working, but there's been some odd moments in the past week
23+
and a bit and, last week, once I got to the end, I was glad for it to end.
24+
So no blog post happened.
25+
26+
Anyway...
27+
28+
<!-- more -->
29+
30+
## What have I been up to?
31+
32+
While mostly sat feeling sorry for myself on my sofa, I have been coding.
33+
Rather than list all the different things here in detail, I'll quickly
34+
mention them with links to where to find them and play with them if you
35+
want:
36+
37+
### FivePyFive
38+
39+
While my Textual 5x5 puzzle is [one of the examples in the Textual
40+
repo](https://github.com/Textualize/textual/tree/main/examples), I wanted to
41+
make it more widely available so people can download it with `pip` or
42+
[`pipx`](https://pypa.github.io/pipx/). See [over on
43+
PyPi](https://pypi.org/project/fivepyfive/) and see if you can solve it. ;-)
44+
45+
<div class="video-wrapper">
46+
<iframe
47+
width="560" height="315"
48+
src="https://www.youtube.com/embed/Rf34Z5r7Q60"
49+
title="PISpy" frameborder="0"
50+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
51+
allowfullscreen>
52+
</iframe>
53+
</div>
54+
55+
### textual-qrcode
56+
57+
I wanted to put together a very small example of how someone may put
58+
together a third party widget library, and in doing so selected what I
59+
thought was going to be a mostly-useless example: [a wrapper around a
60+
text-based QR code generator
61+
website](https://pypi.org/project/textual-qrcode/). Weirdly I've had a
62+
couple of people express a need for QR codes in the terminal since
63+
publishing that!
64+
65+
![A Textual QR Code](../images/2022-12-08-davep-devlog/textual-qrcode.png)
66+
67+
### PISpy
68+
69+
[PISpy](https://pypi.org/project/pispy-client/) is a very simple
70+
terminal-based client for the [PyPi
71+
API](https://warehouse.pypa.io/api-reference/). Mostly it provides a
72+
hypertext interface to Python package details, letting you look up a package
73+
and then follow its dependency links. It's *very* simple at the moment, but
74+
I think more fun things can be done with this.
75+
76+
<div class="video-wrapper">
77+
<iframe
78+
width="560" height="315"
79+
src="https://www.youtube.com/embed/yMGD6bXqIEo"
80+
title="PISpy" frameborder="0"
81+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
82+
allowfullscreen>
83+
</iframe>
84+
</div>
85+
86+
### OIDIA
87+
88+
I'm a big fan of the use of streak-tracking in one form or another.
89+
Personally I use a [streak-tracking app](https://streaksapp.com/) for
90+
keeping tabs of all sorts of good (and bad) habits, and as a heavy user of
91+
all things Apple I make a lot of use of [the Fitness
92+
rings](https://www.apple.com/uk/watch/close-your-rings/), etc. So I got to
93+
thinking it might be fun to do a really simple, no shaming, no counting,
94+
just recording, steak app for the Terminal.
95+
[OIDIA](https://pypi.org/project/oidia/) is the result.
96+
97+
<div class="video-wrapper">
98+
<iframe
99+
width="560" height="315"
100+
src="https://www.youtube.com/embed/3Kz8eUzO9-8"
101+
title="YouTube video player"
102+
frameborder="0"
103+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
104+
allowfullscreen>
105+
</iframe>
106+
</div>
107+
108+
As of the time of writing I only finished the first version of this
109+
yesterday evening, so there are plenty of rough edges; but having got it to
110+
a point where it performed the basic tasks I wanted form it, that seemed
111+
like a good time to publish.
112+
113+
Expect to see this getting more updates and polish.
114+
115+
## Wait, what about this Keymaster thing?
116+
117+
Ahh, yes, about that... So one of the handy things I'm finding about Textual
118+
is its [key binding
119+
system](https://textual.textualize.io/guide/input/#bindings). The more
120+
I build Textual apps, the more I appreciate the bindings, how they can be
121+
associated with specific widgets, the use of actions (which can be used from
122+
other places too), etc.
123+
124+
But... (there's always a "but" right -- I mean, there'd be no blog post to
125+
be had here otherwise).
126+
127+
The terminal doesn't have access to all the key combinations you may want to
128+
use, and also, because some keys can't necessarily be "typed", at least not
129+
easily (think about it: there's no <kbd>F1</kbd> character, you have to type
130+
`F1`), many keys and key combinations need to be bound with specific names.
131+
132+
So there's two problems here: how do I discover what keys even turn up in my
133+
application, and when they do, what should I call them when I pass them to
134+
[`Binding`](https://textual.textualize.io/api/binding/#textual.binding.Binding)?
135+
136+
That felt like a *"well Dave just build an app for it!"* problem. So I did:
137+
138+
<div class="video-wrapper">
139+
<iframe
140+
width="560" height="315"
141+
src="https://www.youtube.com/embed/-MV8LFfEOZo"
142+
title="YouTube video player"
143+
frameborder="0"
144+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
145+
allowfullscreen>
146+
</iframe>
147+
</div>
148+
149+
If you're building apps with Textual and you want to discover what keys turn
150+
up from your terminal and are available to your application, you can:
151+
152+
```sh
153+
$ pipx install textual-keys
154+
```
155+
156+
and then just run `textual-keys` and start mashing the keyboard to find out.
157+
158+
There's a good chance that this app, or at least a version of it, will make
159+
it into Textual itself (very likely as one of the
160+
[devtools](https://textual.textualize.io/guide/devtools/)). But for now it's
161+
just an easy install away.
162+
163+
I think there's a call to be made here too: have you built anything to help
164+
speed up how you work with Textual, or just make the development experience
165+
"just so"? If so, do let is know, and come yell about it on the
166+
[`#show-and-tell`
167+
channel](https://discord.com/channels/1026214085173461072/1033752599112994867)
168+
in [our Discord server](https://discord.gg/Enf6Z3qhVr).

0 commit comments

Comments
 (0)