I started working on this, but was just curious if anyone knows how to find out whether one is using a HiDPI display? (figure.dpi returns 72 even on HiDPI). Also, the subplots.svg file is missing from mpl-data/images - does anyone have this, or will we need to re-make it?
@mdehoon - since you commented on this in #4977, do you have any ideas for how to decide which icons to use? (i.e. is there an easy way to know the monitor resolution?) Or should we just always use the HiDPI ones?
@mdehoon - what would be the best way to expose this at the Python level (since it would be easier to choose the correct icons there)? Should I try adding a method to FigureCanvas or FigureManager in _macosx.m?
I am thinking to load the icon from a PDF file instead of a PNG file (unfortunately SVG is not available in Apple's API). Then the icon file to use is independent of the resolution. If so, do we still need to expose this at the Python level? And if so, how would you use it?
I think this would be useful to expose at the python layer because of partially done/upcoming reworking of the toolbar so exposing this to user specified icons would be good.
With the new toolbar, each tool encapsulates the path to the icon (if none provided it just uses the text) has a class attribute image, but can get overridden by setting it on the object the_tool.image = 'the_filename.png'.
Perhaps we could extend this, either to a preference list... but I have been thinking what do with WebAgg (and NbAgg though I haven't looked at the code there``, so now I think we should have an icon theme dictionary? Something like...
I think I prefer this method, because when we get onto WebAgg, we will have the issue of how to do the icons with the new-toolbar, and I think this method solves it in a very general way and thus highly extendible. What do others think?
I would suggest to leave out the extension of the image file name. Different backends may want to use different file formats; especially for HiDPI-friendly backends it makes sense to use a pdf or svg file, as they can be scaled to any resolution.
@mdehoon - what is required to switch the MacOS X icons to PDF? There are SVG icons so it would be easy to generate the PDF, but what is required code-wise? (or will the PDF icons be automatically recongized?)
See https://github.com/mdehoon/matplotlib/tree/fixForIssue4977MacOSX
Very little is needed. The only remaining point is to have a PDF version of the icon in the same directory as where the PNG, SVG etc. versions are located. Once those are there, I can switch the code to load the PDF instead of the PNG.
Activity
astrofrog commented on Aug 28, 2015
I started working on this, but was just curious if anyone knows how to find out whether one is using a HiDPI display? (figure.dpi returns 72 even on HiDPI). Also, the subplots.svg file is missing from mpl-data/images - does anyone have this, or will we need to re-make it?
astrofrog commented on Aug 28, 2015
@mdehoon - since you commented on this in #4977, do you have any ideas for how to decide which icons to use? (i.e. is there an easy way to know the monitor resolution?) Or should we just always use the HiDPI ones?
mdehoon commented on Aug 29, 2015
For the MacOSX backend, it's a Mac-specific API call. See https://github.com/mdehoon/matplotlib/blob/fixForIssue4977MacOSX/src/_macosx.m between line 4972 and 4992. For other backends I don't know; this will have to come from PyQt5.
astrofrog commented on Aug 29, 2015
@mdehoon - what would be the best way to expose this at the Python level (since it would be easier to choose the correct icons there)? Should I try adding a method to FigureCanvas or FigureManager in _macosx.m?
mdehoon commented on Aug 31, 2015
I am thinking to load the icon from a PDF file instead of a PNG file (unfortunately SVG is not available in Apple's API). Then the icon file to use is independent of the resolution. If so, do we still need to expose this at the Python level? And if so, how would you use it?
tacaswell commented on Aug 31, 2015
I think this would be useful to expose at the python layer because of partially done/upcoming reworking of the toolbar so exposing this to user specified icons would be good.
mdehoon commented on Sep 2, 2015
@astrofrog or @tacaswell can you suggest an API for this? Then I can have a look at how to implement it.
tacaswell commented on Sep 2, 2015
I defer to @OceanWolf and @fariza who are working on the new toolbar with regards to the API for setting icons.
OceanWolf commented on Sep 2, 2015
With the new toolbar, each tool encapsulates the path to the icon (if none provided it just uses the text) has a class attribute image, but can get overridden by setting it on the object the_tool.image = 'the_filename.png'.
Perhaps we could extend this, either to a preference list... but I have been thinking what do with WebAgg (and NbAgg though I haven't looked at the code there``, so now I think we should have an icon theme dictionary? Something like...
I think I prefer this method, because when we get onto WebAgg, we will have the issue of how to do the icons with the new-toolbar, and I think this method solves it in a very general way and thus highly extendible. What do others think?
mdehoon commented on Sep 3, 2015
I would suggest to leave out the extension of the image file name. Different backends may want to use different file formats; especially for HiDPI-friendly backends it makes sense to use a pdf or svg file, as they can be scaled to any resolution.
OceanWolf commented on Sep 3, 2015
Also possible, but I still like the themes idea, something for 2.1 :). Can't wait!
astrofrog commented on Sep 9, 2015
@mdehoon - what is required to switch the MacOS X icons to PDF? There are SVG icons so it would be easy to generate the PDF, but what is required code-wise? (or will the PDF icons be automatically recongized?)
mdehoon commented on Sep 10, 2015
See https://github.com/mdehoon/matplotlib/tree/fixForIssue4977MacOSX
Very little is needed. The only remaining point is to have a PDF version of the icon in the same directory as where the PNG, SVG etc. versions are located. Once those are there, I can switch the code to load the PDF instead of the PNG.
fariza commented on Sep 10, 2015
I was wondering, who uses the ppm and the xpm files?
Is it possible to use the pdf or svg file for all backends?
astrofrog commented on Sep 13, 2015
See #5057 for updated icons for PyQt5
QuLogic commented on Nov 24, 2016
On #5057 @jenshnielsen noted that both the PyQt5 and macOS backends use HiDPI icons with the new icons; are there any other backends that need this?
QuLogic commented on Feb 9, 2018
I'm going to close this as it appears to work on the backends for which we support HiDPI, at least.