diff --git a/changes/194.misc.rst b/changes/194.misc.rst new file mode 100644 index 0000000..87d01ae --- /dev/null +++ b/changes/194.misc.rst @@ -0,0 +1 @@ +The initialization of Chart has been updated to be compatible with Toga 0.5.0. diff --git a/examples/chart/app.py b/examples/chart/app.py index 46346c1..08bf538 100644 --- a/examples/chart/app.py +++ b/examples/chart/app.py @@ -66,16 +66,16 @@ def startup(self): self.chart, toga.Box( children=[toga.Label("𝜇"), self.mu], - style=Pack(padding=(5, 10)), + style=Pack(margin=(5, 10)), ), toga.Box( children=[toga.Label("𝜎"), self.sigma], - style=Pack(padding=(5, 10)), + style=Pack(margin=(5, 10)), ), toga.Button( "Recreate data", on_press=self.recreate_data, - style=Pack(padding=(10, 10, 20, 10)), + style=Pack(margin=(10, 10, 20, 10)), ), ], style=Pack(direction=COLUMN), diff --git a/pyproject.toml b/pyproject.toml index 06fa922..371e7f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,10 @@ classifiers = [ "Topic :: Software Development", "Topic :: Software Development :: User Interfaces", ] +dependencies = [ + "matplotlib >= 3.9.0", + "toga-core >= 0.5.0, < 0.6.0", +] [project.optional-dependencies] # Extras used by developers *of* briefcase are pinned to specific versions to @@ -46,7 +50,7 @@ dev = [ "pytest == 8.3.5", "setuptools_scm == 8.2.0", "tox == 4.25.0", - "toga-dummy >= 0.4.0", + "toga-dummy >= 0.5.0, < 0.6.0", ] # Docs are always built on a specific Python version; see RTD and tox config files. docs = [ diff --git a/src/toga_chart/chart.py b/src/toga_chart/chart.py index 6adaeba..f7a3055 100644 --- a/src/toga_chart/chart.py +++ b/src/toga_chart/chart.py @@ -44,6 +44,7 @@ def __init__( super().__init__(id=id, style=style) + def _create(self): self._impl = self.canvas._impl @Widget.app.setter @@ -193,13 +194,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): # Math mode text must be rendered using paths. # Otherwise, we can use canvas-level text markup. if ismath: - path, transform = self._get_text_path_transform( - x, y, s, prop, angle, ismath - ) - color = gc.get_rgb() - - gc.set_linewidth(0.75) - self.draw_path(gc, path, transform, rgbFace=color) + self._draw_text_as_path(gc, x, y, s, prop, angle, ismath) else: self._canvas.context.translate(x, y) self._canvas.context.rotate(-math.radians(angle))