[Glade-users] Help with a tray icon.

Juan Manuel Mouriz jmouriz at gmail.com
Tue Apr 20 09:16:23 EDT 2010


2010/4/20 Sebastian Alonso <alon.sebastian at gmail.com>:
> This is my first email on the list, so, Hello world!
>
> I have a little problem working with a tray icon, I'm developing with python
> + pyGTK, and I need to have a tray icon, so whenever I minimize the program
> it goes to the tray and whenever I click the tray icon the program comes up
> again...
>
> I'll thank pretty much any help, I've been googleing a lot and never found
> nothing really useful... so, any article, any advice, a tip, whatever,
> everything is really helpful right now :)
>
>
>
> thanks everyone...

Hello,

If your program "comes up again" is because you explicitly make this
somewhere in the code. You must connect activate signal of the tray
icon and use hide/show methods in the callback to manage the window
visibility like this example:

#!/usr/bin/python
import gtk

def visibility_handler(window):
  visible = window.get_property("visible")

  if visible:
    window.hide()
  else:
    window.show()

def activate_callback(icon, window):
  visibility_handler(window)

def delete_callback(window, event):
  visibility_handler(window)

window = gtk.Window()
window.connect("delete-event", delete_callback)

label = gtk.Label("test window")
label.show()
window.add(label)

icon = gtk.StatusIcon()
icon.set_from_stock(gtk.STOCK_YES)
icon.connect("activate", activate_callback, window)
gtk.main()


More information about the Glade-users mailing list