Skip to content

Instantly share code, notes, and snippets.

@AndreaPasqualini
Last active November 29, 2021 14:37
Show Gist options
  • Save AndreaPasqualini/f9dc841bee56a10f4f5653195fdf3657 to your computer and use it in GitHub Desktop.
Save AndreaPasqualini/f9dc841bee56a10f4f5653195fdf3657 to your computer and use it in GitHub Desktop.
Steps to manually fix a bug, where Spyder would not be pinned to the Windows taskbar

Pinning Spyder to the Windows Taskbar

If you install Spyder through Anaconda (or miniconda), its launcher in the Start Menu will behave correctly. However, if you pin it to the taskbar, it won't behave properly. Opening Spyder through that icon on the taskbar will open Spyder, but a new (duplicate) icon on the taskbar will appear. The expected behavior would instead be that the pinned icon represents the application window, and no duplicate icon appears.

To fix this bug, I have followed the instructions as per this comment on this GitHub Issue.

  1. Create a new text file in your preferred location, and call it spyder-taskbar.py with the following contents:
    from win32com.shell import shellcon
    from win32com.propsys import propsys, pscon
    import pythoncom
    
    shortcut_path = r"<anaconda-start-menu-folder>\Spyder.lnk"
    store = propsys.SHGetPropertyStoreFromParsingName(shortcut_path, None, shellcon.GPS_READWRITE, propsys.IID_IPropertyStore)
    store.SetValue(pscon.PKEY_AppUserModel_ID, propsys.PROPVARIANTType(u'spyder.Spyder', pythoncom.VT_LPWSTR))
    store.Commit()
    where <anaconda-start-menu-folder> is the location of Anaconda's folder in the Start Menu (to find it, open the Start Menu, navigate to the anaconda folder, right click on any item inside it and click "Open file location", then read the location bar—you can highlight it with Ctrl+L).
  2. If your Anaconda installation is local (as in "user specific"), then open the Anaconda prompt from the Start Menu. If your installation is system-wide, then open the Anaconda prompt with administrator privileges.
  3. In the prompt, run
    PS C:\> python path\to\spyder-taskbar.py
  4. Restart all instances of explorer.exe (the easiest way is to just restart your computer).
  5. Observe that the Spyder icon in the Anaconda's Start Menu folder is marked as "New".
  6. Pin this new launcher to the taskbar.

Now the new taskbar icon should behave exactly as expected: new windows with Spyder will be captured by the pinned taskbar icon.

Disclaimer

I am not responsible for any damage resulting from the steps above.

Credits

Kudos to @philipstarkey for fiddling with this and finding a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment