4

I'd like to have an icon for Python's Integrated DeveLopment Environement (IDLE) in my launcher. When I've started IDLE via the dash, I can right-click on the icon and choose the 'Lock to Launcher' option. After clicking it, however, the option is still there, whereas it should have been replaced by the 'remove from Launcher' option. So, apparently, this does not work this way. Can I somehow create a custom file making a launcher icon for IDLE appear? The commands that happen when I start IDLE are

stefan@stefan-HP-Pavilion-13-x360-PC:~$ ps ax -f | grep python
stefan    2087  1922  0 12:30 ?        Sl     0:00 /usr/bin/python /usr/bin/glipper
stefan    3318  1751  0 13:14 ?        Sl     0:02 /usr/bin/python3 /usr/bin/idle3
stefan    3325  3318  0 13:14 ?        Sl     0:03 /usr/bin/python3 -c __import__('idlelib.run').run.main(True) 35780
stefan    3348  3124  0 13:19 pts/0    S+     0:00 grep --color=auto python

so I'd somehow have to realize the two commands involving idle with a script.

Edit: When I type /usr/bin/idle3 in my terminal, the other command /usr/bin/python3 -c __import__('idlelib.run').run.main(True) executes automatically, so there is no need to put that into some "starter" script. All the starter does is to execute /usr/bin/idle.

Dragging the icon from the dash directly to the launcher (as Jacob suggested) keeps it in the launcher. However, after clicking it, another icon appears which is different from the starter icon and which has the defect I'm describing here. Maybe that issue can be solved as well?

1 Answers1

7

The simplest solution

Here's what you can do (simpler than you feared :) ):

  • Open Dash
  • Type Idle (or Idle3, depending on the version)
  • Drag the icon from Dash to the Unity Launcher:

    enter image description here

    Then the right- click text sais:

    enter image description here

    (Which is Dutch for: "Remove from launcher")

The command to run Idle

To complete the answer: the command to run Idle is:

/usr/bin/idle

or for specific version(s) e.g.: /usr/bin/idle3, or: /usr/bin/idle-python3.4

Simply look inside the .desktop file in /usr/share/applications in the line, starting with Exec= for the right command.

Prevent an extra icon from Idle when it is launched

Idle produces windows of the WM_CLASS "Toplevel". To make these windows appear under the same icon as you just put in th launcher, do the following:

  • Copy the global idle.desktop file from /usr/share/applications to ~/.local/share/applications.

    cp /usr/share/applications/idle.desktop ~/.local/share/applications
    
  • Open the file (drag it over an open gedit window).

  • Add to the bottom of the file the line:
    StartupWMClass=Toplevel
  • Log out and back in. From then on, all Idle windows will appear under one icon:

    enter image description here

That's it...


EDIT

As a result of the fact that windows of one WM_CLASS in principle only appear under one Launcher icon (at a time) in Unity, please note:

Although the chances are practically none, grouping Toplevel windows under the Idle icon could show a downside in rare situations:

  1. If you run different versions of Idle at the same time (e.g. editing code for two python versions at the same time), all windows are grouped under the icon of the version that started first:

    enter image description here

  2. If you run python applications, using tkinter as a GUI (quite unusual these days), usually secundary windows are set as "child" of the main window by using wm_transient()

    In "unpolished" applications (like Idle), this might not be the case. In such cases, the secondary window ("Toplevel" windows in tkinter), will also show up under the Idle icon, If Idle ran first.

But again, normally this will probably never happen, and if it does, it does no harm but what I described.

Jacob Vlijm
  • 85,475