beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.21k stars 654 forks source link

Include library of standard icons #2441

Open buddha314 opened 4 months ago

buddha314 commented 4 months ago

What is the problem or limitation you are having?

Libraries like Material Design include several platform specific icons. Things like un/filled stars for ratings. Toga only provides the default icon (which is adorable, btw)

Describe the solution you'd like

The ability to do something like icon=toga.Icon.star-filled

Describe alternatives you've considered

downloading entire libraries to my project folder

Additional context

briefly discussed on Discord

freakboy3742 commented 4 months ago

Agreed that this is a gap that Toga should fill.

I can see three approaches that could be taken.

The first is to only wrap the icons for which there is a common platform-specific representation. I've fairly sure all the platforms have "standard" icons for features like "home", "share", "download", "upload", and so on; we would work out what the lowest common subset of those icons are, and provide a guaranteed Toga representation for those icons. The question is whether there actually is a common subset that is large enough to be useful. In this approach, if one platform doesn't provide a "star" icon, then we wouldn't provide a "star" icon as part of Toga's set.

The second approach is the same as the first, but use a "highest common factor" approach - that is, work out a spanning set of icons that we could wrap, and when one platform provides that icon but another doesn't, backfill that missing icon with a Toga-provided one. For this, we'd need to find a source of good open-source compatible, platform-specific icons. If one of the platforms provides a "star" icon, then we backfill all the other platforms with a version that fits that platform's style guide.

The third approach would be to ignore platform icons entirely, and provide integration with a third-party icon set, like Icons8 or FontAwesome. There's 2 issues with this approach: licensing (good icon sets usually have commercial terms), and distribution size (why ship 1000 icons when your app only uses 3?). To do this, I suspect we'd need to ship "toga-icons8" (for example) as a standalone package, and then provide additional tooling to make it easy to install specific icons from the complete set, rather than ship all icons ready-to-use (or maybe there's a on-demand approach

We could possibly support multiple approaches - say, option 2 and 3, where we provide a healthy set of builtin icons, and an expansion path for other icon sets. We could even support multiple icon sets - either with different iconset-specfic packages, or by using a single "toga-iconset" package that can be configured to use different icons sets by configuration or plugin.

tl;dr - I agree this would be a useful feature; the next step will be for someone to research what icons are available by default, and what options exist for platform-specific icon sets - especially if they're platform specific, and/or freely licensed.