I am developing an application in python and it will be used on Windows MacOsX and Linux, and now I am developing a system icon (status icon) (and menu when clicked) in the Mac OSX panel. Can I use PyGTK in windows, mac and linux and use the same code to display the status status in the status bar (macosx), in the system tray (windows) or linux?
Thanks in advance. This is the code:
import gtk
class SystrayIconApp:
def __init__(self):
self.tray = gtk.StatusIcon()
self.tray.set_from_stock(gtk.STOCK_ABOUT)
self.tray.connect('popup-menu', self.on_right_click)
self.tray.set_tooltip(('Sample tray app'))
def on_right_click(self, icon, event_button, event_time):
self.make_menu(event_button, event_time)
def make_menu(self, event_button, event_time):
menu = gtk.Menu()
about = gtk.MenuItem("About")
about.show()
menu.append(about)
about.connect('activate', self.show_about_dialog)
quit = gtk.MenuItem("Quit")
quit.show()
menu.append(quit)
quit.connect('activate', gtk.main_quit)
menu.popup(None, None, gtk.status_icon_position_menu,
event_button, event_time, self.tray)
def show_about_dialog(self, widget):
about_dialog = gtk.AboutDialog()
about_dialog.set_destroy_with_parent (True)
about_dialog.set_icon_name ("SystrayIcon")
about_dialog.set_name('SystrayIcon')
about_dialog.set_version('0.1')
about_dialog.set_copyright("(C) 2010 João Pinto")
about_dialog.set_comments(("Program to demonstrate a system tray icon"))
about_dialog.set_authors(['João Pinto <joao.pinto@getdeb.net>'])
about_dialog.run()
about_dialog.destroy()
if __name__ == "__main__":
SystrayIconApp()
gtk.main()
This is the tray in MAC OS X (star from gtk +):

This is the tray in WINDOWS (star from gtk +):

There is no problem in windows, the menu is displayed when you click the icon, but on the Mac OX the icos icon is displayed, but the menu is not displayed.
What is the problem with the code?
source
share