[Python] python 创建gtk应用程序 →→→→→进入此内容的聊天室

来自 , 2020-11-20, 写在 Python, 查看 150 次.
URL http://www.code666.cn/view/af3b6a54
  1. #!/usr/bin/env python
  2. #
  3. # [SNIPPET_NAME: Create an Application Indicator]
  4. # [SNIPPET_CATEGORIES: Application Indicator]
  5. # [SNIPPET_DESCRIPTION: How to create an application indicator and add items to it]
  6. # [SNIPPET_AUTHOR: Jono Bacon <jono@ubuntu.com>]
  7. # [SNIPPET_DOCS: https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators]
  8. # [SNIPPET_LICENSE: GPL]
  9.  
  10. import pygtk
  11. pygtk.require('2.0')
  12. import gtk
  13. import appindicator
  14.  
  15. class AppIndicatorExample:
  16.     def __init__(self):
  17.         self.ind = appindicator.Indicator ("example-simple-client", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS)
  18.         self.ind.set_status (appindicator.STATUS_ACTIVE)
  19.         self.ind.set_attention_icon ("indicator-messages-new")
  20.         self.ind.set_icon("distributor-logo")
  21.  
  22.         # create a menu
  23.         self.menu = gtk.Menu()
  24.  
  25.         # create items for the menu - labels, checkboxes, radio buttons and images are supported:
  26.        
  27.         item = gtk.MenuItem("Regular Menu Item")
  28.         item.show()
  29.         self.menu.append(item)
  30.  
  31.         check = gtk.CheckMenuItem("Check Menu Item")
  32.         check.show()
  33.         self.menu.append(check)
  34.  
  35.         radio = gtk.RadioMenuItem(None, "Radio Menu Item")
  36.         radio.show()
  37.         self.menu.append(radio)
  38.  
  39.         image = gtk.ImageMenuItem(gtk.STOCK_QUIT)
  40.         image.connect("activate", self.quit)
  41.         image.show()
  42.         self.menu.append(image)
  43.                    
  44.         self.menu.show()
  45.  
  46.         self.ind.set_menu(self.menu)
  47.  
  48.     def quit(self, widget, data=None):
  49.         gtk.main_quit()
  50.  
  51.  
  52. def main():
  53.     gtk.main()
  54.     return 0
  55.  
  56. if __name__ == "__main__":
  57.     indicator = AppIndicatorExample()
  58.     main()
  59. #//python/2299

回复 "python 创建gtk应用程序"

这儿你可以回复上面这条便签

captcha