Note that there are some explanatory texts on larger screens.

plurals
  1. POStatus icon in GTK+ on MacOSX, Windows, and Linux(Gnome) and python
    text
    copied!<p>I'm developing an application in python and it will be used in Windows MacOsX and Linux, and now i'm developing system (status icon) icon (and the menu when you click) in Mac OSX bar. Can I use PyGTK in windows, mac and linux and use the same code for show status icon in status bar (macosx), system tray(windows), or linux?</p> <p>Thanks in advance. This is the code:</p> <pre><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() # show about dialog about = gtk.MenuItem("About") about.show() menu.append(about) about.connect('activate', self.show_about_dialog) # add quit item 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 &lt;joao.pinto@getdeb.net&gt;']) about_dialog.run() about_dialog.destroy() if __name__ == "__main__": SystrayIconApp() gtk.main() </code></pre> <p>This is de tray in MAC OS X (the star from gtk+):</p> <p><img src="https://i.stack.imgur.com/VHwQo.png" alt="This is system tray in MAC OS X"></p> <p>This is the tray in WINDOWS (the star from gtk+):</p> <p><img src="https://i.stack.imgur.com/1i3Ph.png" alt="This is the tray in WINDOWS"></p> <p>On windows no problem, menu is visible when you click the icon, but in Mac OX, icos is showed but menu is not displayed.</p> <p>What is the problem with the code?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload