Skip to content

Commit

Permalink
Merge branch 'main' into alt-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan authored Feb 21, 2023
2 parents 2f09184 + ab3e523 commit a714ffe
Show file tree
Hide file tree
Showing 42 changed files with 1,561 additions and 537 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [0.12.0] - Unreleased

### Added

- Added `App.batch_update` https://github.com/Textualize/textual/pull/1832
- Added horizontal rule to Markdown https://github.com/Textualize/textual/pull/1832
- Added `Widget.disabled` https://github.com/Textualize/textual/pull/1785

### Changed

- Scrolling by page now adds to current position.
- Markdown lists have been polished: a selection of bullets, better alignment of numbers, style tweaks https://github.com/Textualize/textual/pull/1832
- Added alternative method of composing Widgets https://github.com/Textualize/textual/pull/1847

### Removed

- Removed `screen.visible_widgets` and `screen.widgets`


### Fixed

- Numbers in a descendant-combined selector no longer cause an error https://github.com/Textualize/textual/issues/1836


## [0.11.1] - 2023-02-17

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/styles/height_comparison.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

Screen {
layers: ruler;
overflow: hidden;
}

Ruler {
layer: ruler;
dock: right;
overflow: hidden;
width: 1;
background: $accent;
}
2 changes: 2 additions & 0 deletions docs/guide/CSS.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ The `background: green` is only applied to the Button underneath the mouse curso

Here are some other pseudo classes:

- `:disabled` Matches widgets which are in a disabled state.
- `:enabled` Matches widgets which are in an enabled state.
- `:focus` Matches widgets which have input focus.
- `:focus-within` Matches widgets with a focused a child widget.

Expand Down
6 changes: 3 additions & 3 deletions examples/dictionary.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Input {
}

#results {
width: auto;
min-height: 100%;
padding: 0 1;
width: 100%;
height: auto;

}

#results-container {
Expand Down
14 changes: 9 additions & 5 deletions examples/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
except ImportError:
raise ImportError("Please install httpx with 'pip install httpx' ")

from rich.markdown import Markdown

from textual.app import App, ComposeResult
from textual.containers import Content
from textual.widgets import Input, Static
from textual.widgets import Input, Markdown


class DictionaryApp(App):
Expand All @@ -36,17 +35,22 @@ async def on_input_changed(self, message: Input.Changed) -> None:
asyncio.create_task(self.lookup_word(message.value))
else:
# Clear the results
self.query_one("#results", Static).update()
await self.query_one("#results", Markdown).update("")

async def lookup_word(self, word: str) -> None:
"""Looks up a word."""
url = f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}"
async with httpx.AsyncClient() as client:
results = (await client.get(url)).json()
response = await client.get(url)
try:
results = response.json()
except Exception:
self.query_one("#results", Static).update(response.text)
return

if word == self.query_one(Input).value:
markdown = self.make_word_markdown(results)
self.query_one("#results", Static).update(Markdown(markdown))
await self.query_one("#results", Markdown).update(markdown)

def make_word_markdown(self, results: object) -> str:
"""Convert the results in to markdown."""
Expand Down
26 changes: 26 additions & 0 deletions examples/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ Two tildes indicates strikethrough, e.g. `~~cross out~~` render ~~cross out~~.

Inline code is indicated by backticks. e.g. `import this`.

## Lists

1. Lists can be ordered
2. Lists can be unordered
- I must not fear.
- Fear is the mind-killer.
- Fear is the little-death that brings total obliteration.
- I will face my fear.
- I will permit it to pass over me and through me.
- And when it has gone past, I will turn the inner eye to see its path.
- Where the fear has gone there will be nothing. Only I will remain.

### Longer list

1. **Duke Leto I Atreides**, head of House Atreides
2. **Lady Jessica**, Bene Gesserit and concubine of Leto, and mother of Paul and Alia
3. **Paul Atreides**, son of Leto and Jessica
4. **Alia Atreides**, daughter of Leto and Jessica
5. **Gurney Halleck**, troubadour warrior of House Atreides
6. **Thufir Hawat**, Mentat and Master of Assassins of House Atreides
7. **Duncan Idaho**, swordmaster of House Atreides
8. **Dr. Wellington Yueh**, Suk doctor of House Atreides
9. **Leto**, first son of Paul and Chani who dies as a toddler
10. **Esmar Tuek**, a smuggler on Arrakis
11. **Staban Tuek**, son of Esmar

## Fences

Fenced code blocks are introduced with three back-ticks and the optional parser. Here we are rendering the code in a sub-widget with syntax highlighting and indent guides.
Expand Down
7 changes: 3 additions & 4 deletions examples/five_by_five.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

"""Simple version of 5x5, developed for/with Textual."""

from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING, cast

Expand Down Expand Up @@ -192,8 +192,7 @@ def game_playable(self, playable: bool) -> None:
Args:
playable (bool): Should the game currently be playable?
"""
for cell in self.query(GameCell):
cell.disabled = not playable
self.query_one(GameGrid).disabled = not playable

def cell(self, row: int, col: int) -> GameCell:
"""Get the cell at a given location.
Expand Down
2 changes: 1 addition & 1 deletion src/textual/_arrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ def arrange(

placements.extend(layout_placements)

return placements, arrange_widgets, scroll_spacing
return DockArrangeResult(placements, arrange_widgets, scroll_spacing)
Loading

0 comments on commit a714ffe

Please sign in to comment.