Skip to content

Commit 311229f

Browse files
Merge branch 'main' into fix-1335
2 parents 0c708de + 54a2e3e commit 311229f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1990
-588
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: check-yaml
1010
args: ['--unsafe']
1111
- repo: https://github.com/psf/black
12-
rev: 22.3.0
12+
rev: 22.10.0
1313
hooks:
1414
- id: black
1515
exclude: ^tests/

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2525

2626
- Type selectors can now contain numbers https://github.com/Textualize/textual/issues/1253
2727
- Fixed visibility not affecting children https://github.com/Textualize/textual/issues/1313
28+
- Fixed issue with auto width/height and relative children https://github.com/Textualize/textual/issues/1319
29+
- Fixed issue with offset applied to containers https://github.com/Textualize/textual/issues/1256
2830
- Fixed default CSS retrieval for widgets with no `DEFAULT_CSS` that inherited from widgets with `DEFAULT_CSS` https://github.com/Textualize/textual/issues/1335
2931

3032
## [0.5.0] - 2022-11-20

docs/api/list_item.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: textual.widgets.ListItem

docs/api/list_view.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: textual.widgets.ListView

docs/api/text_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: textual.widgets.TextLog
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 from 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 us 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).

docs/examples/guide/layout/combining_layouts.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
grid-rows: 1fr;
66
}
77

8-
#left-pane > Static {
8+
#left-pane > Static {
99
background: $boost;
1010
color: auto;
1111
margin-bottom: 1;
1212
padding: 1;
1313
}
1414

1515
#left-pane {
16+
height: 100%;
1617
row-span: 2;
1718
background: $panel;
1819
border: dodgerblue;
1920
}
2021

2122
#top-right {
23+
height: 100%;
2224
background: $panel;
2325
border: mediumvioletred;
2426
}
@@ -31,6 +33,7 @@
3133
}
3234

3335
#bottom-right {
36+
height: 100%;
3437
layout: grid;
3538
grid-size: 3;
3639
grid-columns: 1fr;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Screen {
2+
align: center middle;
3+
}
4+
5+
ListView {
6+
width: 30;
7+
height: auto;
8+
margin: 2 2;
9+
}
10+
11+
Label {
12+
padding: 1 2;
13+
}

docs/examples/widgets/list_view.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from textual.app import App, ComposeResult
2+
from textual.widgets import ListView, ListItem, Label, Footer
3+
4+
5+
class ListViewExample(App):
6+
def compose(self) -> ComposeResult:
7+
yield ListView(
8+
ListItem(Label("One")),
9+
ListItem(Label("Two")),
10+
ListItem(Label("Three")),
11+
)
12+
yield Footer()
13+
14+
15+
app = ListViewExample(css_path="list_view.css")
16+
if __name__ == "__main__":
17+
app.run()

0 commit comments

Comments
 (0)