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?

11
  • Yes, that can be fixed as well, see my updated answer. Sep 10, 2015 at 12:55
  • @JacobVlijm: It seems like the usage for the idle tag is ambiguous, but most askers seem to use it for questions about how to get something to be done when something is idle. Sep 10, 2015 at 13:42
  • Aaarggh, my bad, removed it... I should have known without the capital. Sep 10, 2015 at 13:43
  • You were not the only one using it this way :-) Could we actually have two tags, one idle and another one "IDLE" with capital letters? Sep 10, 2015 at 13:49
  • 1
    @JacobVlijm: I see you've been quite busy with retagging a lot of questions. Good work! Sep 10, 2015 at 18:19

1 Answer 1

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.

6
  • The gets the icon to the launcher. However, when I click it, a new icon appears which is different from the starter and which has the flaw I described in my answer. So I'd call this a workaround. Anyway, +1, and thanks for the answer. Sep 10, 2015 at 12:38
  • @StefanHamcke we can probably solve that as well, wait a minute... Sep 10, 2015 at 12:40
  • 1
    Oh, I see, so when I type /usr/bin/idle3 in my terminal, the other command /usr/bin/python3 -c __import__('idlelib.run').run.main(True) 50649 "happens" automatically, so there is no need to put that into some "starter" script. Sep 10, 2015 at 12:43
  • @StefanHamcke exactly. The command to run Idle is in the .desktop file as well. Sep 10, 2015 at 12:44
  • Great! You're a genius :-) Sep 10, 2015 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .