feat: add icons on buttons#598
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #598 +/- ##
==========================================
+ Coverage 87.68% 87.80% +0.11%
==========================================
Files 39 39
Lines 4573 4617 +44
==========================================
+ Hits 4010 4054 +44
Misses 563 563
☔ View full report in Codecov by Sentry. |
Czaki
left a comment
There was a problem hiding this comment.
it looks nice.
Shor check of ipywidgets code suggests that it may be possible to easily contribute to enable arbitrary SVG on buttons.
| @@ -1,3 +1,5 @@ | |||
| # from __future__ import annotations # NO | |||
There was a problem hiding this comment.
Why? (it may be nice to learn).
There was a problem hiding this comment.
Oh just a silly reason, cause I use the annotations at runtime internally in this module. I can add a comment
| try: | ||
| return superqt.QIconifyIcon(key, color=color) | ||
| except (OSError, ValueError) as e: | ||
| warnings.warn(f"Could not set iconify icon: {e}", stacklevel=2) | ||
| return None |
There was a problem hiding this comment.
Does this will handle HTTP errors if someone try to use it the first time on a machine without internet access?
There was a problem hiding this comment.
Yeah I believe it should (that was my intention anyway). Requests HTTP errors are subclasses of OSError
You mean like an upstream PR? That's a good idea |
|
I opened jupyter-widgets/ipywidgets#3850 for discussion, but probably won't wait here for it |
this PR allows adding icons to buttons, it uses superqt's recently added iconify support (pyapp-kit/superqt#209) and ipywidget's built in support for fontawesome 5. So you can do something like this:
Note that qt will have the full selection of all icons available in iconify, but ipywidgets only works when the icon string after the colon is valid in fontawesome 4/5. In some cases (if you don't use font-awesome prefix as shown in the example above) that will mean a different appearance in qt. If you want the icons to look similar in both backends, just restrict yourself to fontawesome-5