Skip to content

Commit

Permalink
button tweak (#3539)
Browse files Browse the repository at this point in the history
* button tweak

* changelog
  • Loading branch information
willmcgugan authored Oct 16, 2023
1 parent ddbc91e commit 6ed6011
Show file tree
Hide file tree
Showing 3 changed files with 986 additions and 980 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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

### Changed

- Buttons will now display multiple lines, and have auto height https://github.com/Textualize/textual/pull/3539

## [0.40.0] - 2023-10-11

- Added `loading` reactive property to widgets https://github.com/Textualize/textual/pull/3509
Expand Down
10 changes: 5 additions & 5 deletions src/textual/widgets/_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from functools import partial

import rich.repr
from rich.console import RenderableType
from rich.padding import Padding
from rich.text import Text, TextType
from typing_extensions import Literal, Self

Expand Down Expand Up @@ -33,7 +35,7 @@ class Button(Static, can_focus=True):
Button {
width: auto;
min-width: 16;
height: 3;
height: auto;
background: $panel;
color: $text;
border: none;
Expand Down Expand Up @@ -228,10 +230,8 @@ def validate_label(self, label: TextType) -> TextType:
return Text.from_markup(label)
return label

def render(self) -> TextType:
label = Text.assemble(" ", self.label, " ")
label.stylize(self.text_style)
return label
def render(self) -> RenderableType:
return Padding(self.label, (0, 1), expand=False)

async def _on_click(self, event: events.Click) -> None:
event.stop()
Expand Down
Loading

0 comments on commit 6ed6011

Please sign in to comment.