Skip to content

Commit

Permalink
Merge pull request #6 from Textualize/better-resize
Browse files Browse the repository at this point in the history
Address a problem with plots' sizes appearing to cap at their last `clf`
  • Loading branch information
davep authored Oct 25, 2023
2 parents be2d422 + 467610a commit 040a6c7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# textual-plotext ChangeLog

## [0.2.1] - 2023-10-25

### Fixed

- Fixed an issue with plots' sizes capping at their last `clf` size.
https://github.com/Textualize/textual-plotext/issues/5

## [0.2.0] - 2023-10-25

### Added
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "textual-plotext"
version = "0.2.0"
version = "0.2.1"
description = "A Textual widget wrapper for the Plotext plotting library"
homepage = "https://github.com/Textualize/textual-plotext"
repository = "https://github.com/Textualize/textual-plotext"
Expand Down
3 changes: 3 additions & 0 deletions src/textual_plotext/plotext/_figure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,7 @@ class _figure_class:
self, width: int | None = None, height: int | None = None
) -> None: ...
def plotsize(self, width: int | None = None, height: int | None = None) -> None: ...
def _set_size(
self, width: int | None = None, height: int | None = None
) -> None: ...
def take_min(self) -> None: ...
10 changes: 10 additions & 0 deletions src/textual_plotext/plotext_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def render(self) -> RenderResult:
The renderable for displaying the plot.
"""
self._plot.plotsize(self.size.width, self.size.height)
# This is a belt-and-braces setting of the size of the plot.
# Internally plotsize calls _set_plot, and as best as I can figure
# out, what I'm doing here *should* be a no-op (or rather a repeat
# of what I've just done). And yet... the resizing of plots just
# doesn't work right without this. This *might* be some
# as-yet-undiscovered side-effect of dumpster-diving for the figure
# class.
#
# https://github.com/Textualize/textual-plotext/issues/5
self._plot._set_size(self.size.width, self.size.height)
if self.auto_theme:
self._plot.theme(
self.dark_mode_theme if self.app.dark else self.light_mode_theme
Expand Down

0 comments on commit 040a6c7

Please sign in to comment.