PDA

View Full Version : Tray icon using PyGTK


Fipaj
April 9th, 2006, 12:43 PM
Hi!
I'm modyfing a little IRC app called Urk (I don't know Python well but this application is so simple...). One of new features listed by me is to minimize program to tray...

Can anybody write me an example for this action? I have already searched Net, but I didn't find anything useful.

Thanks!
Filip Konarowski

nanotube
April 9th, 2006, 02:41 PM
check out the pygtk page (http://www.pygtk.org/), and search for word "trayicon"

you will see that a package called GnomePythonExtras provides an interface for making trayicons in gnome. that should be helpful.

Fipaj
April 10th, 2006, 09:19 AM
Yes, thanks. But... there's no search on PyGTK.org, and using Google (trayicon site:pygtk.org) i found nothing...

llonesmiz
April 10th, 2006, 11:29 AM
You should install the packages python-gnome2-extras, python-gnome2-extras-dev and python-gnome2-extras-doc. Then you can find an example program at /usr/share/doc/python-gnome2-extras/examples/egg/trayicon.py. I'm using dapper but it should be the same in breezy.

psychicdragon
April 10th, 2006, 04:01 PM
Here's a quick example:
#! /usr/bin/python

import gtk
import egg.trayicon # egg == python-gnome2-extras

def callback(widget, ev):
print "Button %i pressed!" % ev.button


tray = egg.trayicon.TrayIcon("TrayIcon")
box = gtk.EventBox()
label = gtk.Label("Click Me!")
box.add(label)
tray.add(box)
tray.show_all()

box.connect("button-press-event", callback)

gtk.main()

solarwind
May 10th, 2008, 04:18 PM
Here's a quick example:
#! /usr/bin/python

import gtk
import egg.trayicon # egg == python-gnome2-extras

def callback(widget, ev):
print "Button %i pressed!" % ev.button


tray = egg.trayicon.TrayIcon("TrayIcon")
box = gtk.EventBox()
label = gtk.Label("Click Me!")
box.add(label)
tray.add(box)
tray.show_all()

box.connect("button-press-event", callback)

gtk.main()


Is there any documentation on egg.trayicon?

imdano
May 10th, 2008, 04:52 PM
egg.trayicon is actually deprecated, but I've used it for backwards compatibility before (gtk.StatusIcon is somewhat new). I couldn't find any documentation on it though, I just looked for code samples.

solarwind
May 10th, 2008, 05:17 PM
egg.trayicon is actually deprecated, but I've used it for backwards compatibility before (gtk.StatusIcon is somewhat new). I couldn't find any documentation on it though, I just looked for code samples.

Well, I need something (anything, I don't care), that will let me stick an icon and a label in the system tray with c++. Does either gtk.StatusIcon or the egg thing let me put a label or other simple widget in the system tray?

nanotube
May 11th, 2008, 07:23 PM
Well, I need something (anything, I don't care), that will let me stick an icon and a label in the system tray with c++. Does either gtk.StatusIcon or the egg thing let me put a label or other simple widget in the system tray?

yes it does. if you don't care about supporting versions of gtk prior to 2.10, use gtk.StatusIcon. it's nice.