This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE app icon is blurry on macOS with Aqua Tk 8.6
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: benjamin.peterson, miss-islington, ned.deily, serhiy.storchaka, taleinat, terry.reedy, wordtech
Priority: normal Keywords: patch

Created on 2017-11-25 04:49 by wordtech, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Screen Shot 2017-11-24 at 11.44.31 PM.png wordtech, 2017-11-25 04:49
pyshell.diff wordtech, 2017-11-25 13:39
Pull Requests
URL Status Linked Edit
PR 12031 merged ned.deily, 2019-02-25 16:42
PR 12034 merged ned.deily, 2019-02-25 18:02
PR 12133 merged miss-islington, 2019-03-01 22:54
Messages (15)
msg306941 - (view) Author: Kevin Walzer (wordtech) * Date: 2017-11-25 04:49
The trunk and 8.6.7 branch of Tk on macOS have recently implemented the wm_iconphoto command, which had not previously been supported on macOS. This means that versions of IDLE that link to this version of Tk will inherit the iconphoto behavior on Windows and X11, which results in a extremely blurry icon image in the Dock. It would probably be best to make this command conditional on macOS to just retain the standard app icon, or else add a sharper image.
msg306948 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-11-25 07:28
Here is the current code in idlelib.pyshell.main.

    # set application icon
    icondir = os.path.join(os.path.dirname(__file__), 'Icons')
    if system() == 'Windows':
        iconfile = os.path.join(icondir, 'idle.ico')
        root.wm_iconbitmap(default=iconfile)
    else:
        ext = '.png' if TkVersion >= 8.6 else '.gif'
        iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext))
                     for size in (16, 32, 48)]
        icons = [PhotoImage(master=root, file=iconfile)
                 for iconfile in iconfiles]
        root.wm_iconphoto(True, *icons)

IDLE uses wm_iconbitmap on Windows and wm_iconphoto with PhotoImages from .gif or .png on everything else.  It appears that wm_iconphoto is already used on macOS with tk 8.5.

The uploaded PM.png looks like it might be idle16.png zoomed out at least 3x.  Anything that does that instead of using the much sharper 32 or 48 bit versions is, to me, buggy.  The bigger images stay much sharper even when zoomed.
msg306955 - (view) Author: Kevin Walzer (wordtech) * Date: 2017-11-25 13:38
wm_iconphoto is a no-op on Tk 8.5 on MacOS; the C function returns true with no action. That's why this has not cropped up before.

As implemented, the command on macOS only takes the first image in the parameters to use; the Cocoa mechanism in use for displaying images as app icons does not pack multiple sizes in the image. This will be documented in the man page for the next release of Tk. That's why the image currently looks very bad, because, as you note, it's scaling up a 16px image. The 48px would look better, albeit a bit jagged. 

The attached patch proposes to simply bypass this call in Tk-Mac. The wm_iconphoto command is most useful for a) replacing a generic Windows or X11 icon with something more customized or b) displaying a change in application state. On Mac OS, option is already addressed by the bundled application icon that looks much more polished; most users will not be calling idle from the command line (where this call can make sense). Option b is not applicable in this context.
msg306956 - (view) Author: Kevin Walzer (wordtech) * Date: 2017-11-25 13:39
Adding proposed patch.
msg306968 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-11-25 17:51
Ned, do you agree that simply changing 'else' to 'elif not macosx.isAquaTk()' is the best resolution?

Backporting such a change to 3.6 would be trivial; to 2.7, not.  Is there any need for the latter?

Kevin, thanks for the explanation.
msg306969 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-25 18:06
If on OS X only first picture is taken, what if change the order of pictures?
msg334408 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-26 23:54
A Branch Seidenman posted 'Retina Icons' on idle-dev.  He posted a screenshot similar to Kevin's.  He says Apple recommends having all these sizes:
1024px × 1024px
512px × 512px
256px × 256px
128px × 128px
64px × 64px
32px × 32px
16px × 16px

Creating new icons larger that 48px is beyond me.  Besides which, I believe these are copies of files elsewhere in the repository.  (The icons directory should have a README explaining the files and their origin.  How many of these sizes would actually be useful?  Would larger icons be useful on hi-rex Linux (or even Windows) systems?
msg334412 - (view) Author: Kevin Walzer (wordtech) * Date: 2019-01-27 02:48
Making the icon 512x512 pixels will make it look correct on Retina displays on the Mac.
msg336517 - (view) Author: Kevin Walzer (wordtech) * Date: 2019-02-25 12:49
Is there any reason not to commit the patch I submitted to address this issue?As an alternative I can submit a high-res PNG that can be used, and will submit a different patch to incorporate it, which would work from either the standard app bundle or the command line. Either way, there is no reason to continue to have this visual artifact in IDLE on the Mac.
msg336547 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-02-25 18:20
Thanks, Kevin, for the reminder.  Yeah, there's no reason not to push this.  I've attached PRs for 3.x and for 2.7.
msg336964 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-03-01 22:53
New changeset 7eebbbd5b3907447eddadf5cb7cb1cc9230d15b2 by Terry Jan Reedy (Ned Deily) in branch 'master':
bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. (GH-12031)
https://github.com/python/cpython/commit/7eebbbd5b3907447eddadf5cb7cb1cc9230d15b2
msg336966 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-03-01 23:12
New changeset 453100f60e3c297226eaf0b0b4eb8c817a73b5ce by Ned Deily in branch '2.7':
bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. Original patch by Kevin Walzer. (GH-12034)
https://github.com/python/cpython/commit/453100f60e3c297226eaf0b0b4eb8c817a73b5ce
msg336967 - (view) Author: miss-islington (miss-islington) Date: 2019-03-01 23:14
New changeset 243b2064ce4fb7f90e69f9a4fa9c7e7ec70eba17 by Miss Islington (bot) in branch '3.7':
bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. (GH-12031)
https://github.com/python/cpython/commit/243b2064ce4fb7f90e69f9a4fa9c7e7ec70eba17
msg336978 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-03-02 01:13
After patching my 3.7.2 Macbook installation, and reviewing #20406 which added the icon code, I understand this issue better.  IDLE, while open and unlike other Mac apps I later tested, was replacing the initial Mac IDLE app dock icon (tilted page with double snakes and pen) with the cross-platform IDLE icon.

This was an accidental side-effect.  #20406 replaced the tk icon on the title bar of IDLE windows with the little IDLE icons.  Before merging, I checked that this did not affect the large app icons on the taskbar.  I assume that Serhiy did the equivalent on Linux.  I don't think that the patch was visually checked on Mac.

After the patch, I noticed that the normal behavior with macOS is to put a barely visible (to my eyes) black dot under dock icons when an app is open.  On Windows, the icon is also left as is, but a much more visible icon-width underline is added while open.  I approve of removing the while-open overlay on Mac and don't think it needs to be reinstated.
---

Kevin, I suspect that higher resolution .pngs (64px, 128px?) would help on other *nixes, (and perhaps Windows), but this would be another issue.  Whatever is in the .ico file for Windows looks awful in the corner of IDLE windows on my system, but this also is another issue.
msg337018 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2019-03-02 19:12
New changeset 59e824b4fc314b10c5d24ff0bf737a15787f0574 by Benjamin Peterson (Ned Deily) in branch '2.7':
bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. Original patch by Kevin Walzer. (GH-12034)
https://github.com/python/cpython/commit/59e824b4fc314b10c5d24ff0bf737a15787f0574
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76310
2019-03-02 19:12:15benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg337018
2019-03-02 01:13:19terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg336978

stage: patch review -> resolved
2019-03-01 23:14:00miss-islingtonsetnosy: + miss-islington
messages: + msg336967
2019-03-01 23:12:47ned.deilysetmessages: + msg336966
2019-03-01 22:54:13miss-islingtonsetstage: commit review -> patch review
pull_requests: + pull_request12136
2019-03-01 22:53:53terry.reedysetmessages: + msg336964
2019-02-25 18:20:32ned.deilysettitle: Icon on macOS -> IDLE app icon is blurry on macOS with Aqua Tk 8.6
stage: patch review -> commit review
messages: + msg336547
versions: + Python 2.7, Python 3.7, Python 3.8
2019-02-25 18:02:39ned.deilysetpull_requests: + pull_request12064
2019-02-25 16:42:59ned.deilysetstage: patch review
pull_requests: + pull_request12061
2019-02-25 12:49:50wordtechsetmessages: + msg336517
2019-01-27 02:48:28wordtechsetmessages: + msg334412
2019-01-26 23:54:55terry.reedysetnosy: + taleinat
messages: + msg334408
2017-11-25 18:06:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg306969
2017-11-25 17:51:09terry.reedysetmessages: + msg306968
2017-11-25 13:39:19wordtechsetfiles: + pyshell.diff
keywords: + patch
messages: + msg306956
2017-11-25 13:38:44wordtechsetmessages: + msg306955
2017-11-25 07:28:57terry.reedysetnosy: + ned.deily
messages: + msg306948
2017-11-25 04:49:36wordtechcreate