Advertisement
Guest User

Untitled

a guest
Oct 10th, 2011
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. from gi.repository import Gtk
  2.  
  3. class aStatusIcon:
  4.     def __init__(self):
  5.         self.statusicon = Gtk.StatusIcon()
  6.         self.statusicon.set_from_stock(Gtk.STOCK_HOME)
  7.         self.statusicon.connect("popup-menu", self.right_click_event)
  8.  
  9.         window = Gtk.Window()
  10.         window.connect("destroy", lambda w: Gtk.main_quit())
  11.         window.show_all()
  12.  
  13.     def right_click_event(self, icon, button, time):
  14.         self.menu = Gtk.Menu()
  15.  
  16.         about = Gtk.MenuItem()
  17.         about.set_label("About")
  18.         quit = Gtk.MenuItem()
  19.         quit.set_label("Quit")
  20.  
  21.         about.connect("activate", self.show_about_dialog)
  22.         quit.connect("activate", Gtk.main_quit)
  23.  
  24.         self.menu.append(about)
  25.         self.menu.append(quit)
  26.  
  27.         self.menu.show_all()
  28.  
  29.     def pos(menu, icon):
  30.         return (Gtk.StatusIcon.position_menu(menu, icon))
  31.  
  32.         self.menu.popup(None, None, pos, self.statusicon, button, time)
  33.  
  34.     def show_about_dialog(self, widget):
  35.         about_dialog = Gtk.AboutDialog()
  36.  
  37.         about_dialog.set_destroy_with_parent(True)
  38.         about_dialog.set_name("StatusIcon Example")
  39.         about_dialog.set_version("1.0")
  40.         about_dialog.set_authors(["Andrew Steele"])
  41.  
  42.         about_dialog.run()
  43.         about_dialog.destroy()
  44.  
  45. aStatusIcon()
  46. Gtk.main()
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement