Skip to content
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

IDLE app icon is blurry on macOS with Aqua Tk 8.6 #76310

Closed
wordtech mannequin opened this issue Nov 25, 2017 · 15 comments
Closed

IDLE app icon is blurry on macOS with Aqua Tk 8.6 #76310

wordtech mannequin opened this issue Nov 25, 2017 · 15 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@wordtech
Copy link
Mannequin

wordtech mannequin commented Nov 25, 2017

BPO 32129
Nosy @terryjreedy, @taleinat, @benjaminp, @ned-deily, @serhiy-storchaka, @miss-islington
PRs
  • bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. #12031
  • [2.7] bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. #12034
  • [3.7] bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. (GH-12031) #12133
  • Files
  • Screen Shot 2017-11-24 at 11.44.31 PM.png
  • pyshell.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2019-03-02.01:13:19.261>
    created_at = <Date 2017-11-25.04:49:36.218>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE app icon is blurry on macOS with Aqua Tk 8.6'
    updated_at = <Date 2019-03-02.19:12:15.104>
    user = 'https://bugs.python.org/wordtech'

    bugs.python.org fields:

    activity = <Date 2019-03-02.19:12:15.104>
    actor = 'benjamin.peterson'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-03-02.01:13:19.261>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2017-11-25.04:49:36.218>
    creator = 'wordtech'
    dependencies = []
    files = ['47288', '47293']
    hgrepos = []
    issue_num = 32129
    keywords = ['patch']
    message_count = 15.0
    messages = ['306941', '306948', '306955', '306956', '306968', '306969', '334408', '334412', '336517', '336547', '336964', '336966', '336967', '336978', '337018']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'taleinat', 'wordtech', 'benjamin.peterson', 'ned.deily', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['12031', '12034', '12133']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32129'
    versions = ['Python 2.7', 'Python 3.7', 'Python 3.8']

    @wordtech
    Copy link
    Mannequin Author

    wordtech mannequin commented Nov 25, 2017

    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.

    @wordtech wordtech mannequin assigned terryjreedy Nov 25, 2017
    @wordtech wordtech mannequin added topic-IDLE type-bug An unexpected behavior, bug, or error labels Nov 25, 2017
    @terryjreedy
    Copy link
    Member

    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.

    @wordtech
    Copy link
    Mannequin Author

    wordtech mannequin commented Nov 25, 2017

    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.

    @wordtech
    Copy link
    Mannequin Author

    wordtech mannequin commented Nov 25, 2017

    Adding proposed patch.

    @terryjreedy
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    If on OS X only first picture is taken, what if change the order of pictures?

    @terryjreedy
    Copy link
    Member

    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?

    @wordtech
    Copy link
    Mannequin Author

    wordtech mannequin commented Jan 27, 2019

    Making the icon 512x512 pixels will make it look correct on Retina displays on the Mac.

    @wordtech
    Copy link
    Mannequin Author

    wordtech mannequin commented Feb 25, 2019

    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.

    @ned-deily
    Copy link
    Member

    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.

    @ned-deily ned-deily added 3.7 (EOL) end of life 3.8 only security fixes labels Feb 25, 2019
    @ned-deily ned-deily changed the title Icon on macOS IDLE app icon is blurry on macOS with Aqua Tk 8.6 Feb 25, 2019
    @terryjreedy
    Copy link
    Member

    New changeset 7eebbbd by Terry Jan Reedy (Ned Deily) in branch 'master':
    bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. (GH-12031)
    7eebbbd

    @ned-deily
    Copy link
    Member

    New changeset 453100f 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)
    453100f

    @miss-islington
    Copy link
    Contributor

    New changeset 243b206 by Miss Islington (bot) in branch '3.7':
    bpo-32129: Avoid blurry IDLE application icon on macOS with Tk 8.6. (GH-12031)
    243b206

    @terryjreedy
    Copy link
    Member

    After patching my 3.7.2 Macbook installation, and reviewing bpo-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. bpo-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.

    @benjaminp
    Copy link
    Contributor

    New changeset 59e824b 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)
    59e824b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants