-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? (it may be nice to learn).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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