Future-proof Chart against changing Toga Widget initialization#194
Conversation
freakboy3742
left a comment
There was a problem hiding this comment.
Agreed this makes sense in the light of beeware/toga#2942 changes; one possible way to avoid the backwards incompatibility at all, plus any additional changes that are needed as a result of the final review state of beeware/toga#2942.
| if not self._impl: | ||
| # Backwards compatibility for Toga 0.4.8, which does not call the _create() | ||
| # method in Widget.__init__() | ||
| self._create() |
There was a problem hiding this comment.
We can also fix this by a toga dependency to toga-core>=0.4.8. It's an interesting omission that we don't currently have that dependency, only enforcing the toga-dummy requirement on developers.
There was a problem hiding this comment.
Oh. Yeah. That is a good point! I'll just change it to that once we know for sure what the next version number is.
There was a problem hiding this comment.
I've removed the backwards compatibility shim and added the version requirement (which fails for now, of course, since Toga 0.5.0 doesn't exist).
|
So this works with updated Toga now, but a Matplotlib change is an issue. Looks like we're calling an internal method, toga-chart/src/toga_chart/chart.py Lines 195 to 202 in 0d6bf03 I've not yet looked into it enough to know the best way to adapt. (Strangely, even when I remove that call, I start seeing weird layout breaks from resizing, like in #191, but without any console errors. May or may not be caused by this same spot in the code, one way or another.) |
Looking at the PR that removed the method - the naive approach would seem to be On a semi-related notes - I seem to recall hitting an issue with a matplotlib update a few months back that would cause issues when the chart is on option container and isn't visible. At the time, the "fix" was to pin an older version of matplotlib, but if we're updating the version, it might be worth checking this as well. |
|
Speaking of updating versions and matplotlib, shouldn't toga-chart declare a dependency on matplotlib, I imagine? |
Um... yes it should... how has that gone unnoticed?! Looking through my archives, my demo projects using toga-chart have always declared the dependency on matplotlib, so it's always worked. |
| @@ -47,6 +47,7 @@ dev = [ | |||
| "setuptools_scm == 8.2.0", | |||
| "tox == 4.24.2", | |||
| "toga-dummy >= 0.4.0", | |||
There was a problem hiding this comment.
can remove "toga-dummy >= 0.4.0", due to "toga-dummy >= 0.5.0, < 0.6.0",
There was a problem hiding this comment.
Now that toga 0.5.0 is out, is there a reason to remove the range you had before? "toga >= 0.5.0, < 0.6.0",
941910b to
e198ad8
Compare
freakboy3742
left a comment
There was a problem hiding this comment.
I've worked out the workaround for _get_text_path_transform - it turns out the _draw_text_as_path has always existed, and does what we need anyway.
I've also added in the dependency declarations for matplotlib and toga-core.
|
Thanks for handling this, Russ! (I've been rather preoccupied the last couple of weeks, but I do still exist.) 😉 |
No problem at all - I hit some issues updating some presentations for PyConUS, which forced the issue. |
Updates Chart to play nice with the restructured Widget initialization in beeware/toga#2942, while staying backwards compatibile with Toga 0.4.8.
I realize that PR may or may not change significantly before merging; this is for its current form as of beeware/toga@c4db37f, and I can amend as needed.
PR Checklist: