statusicon.py

来自「使用Pygtk写的几个例子」· Python 代码 · 共 32 行

PY
32
字号
#!/usr/bin/env python'''Status IconThis is a simple example that shows how to create a status icon thatwill appear in the "notification area" in GNOME/KDE, or "system tray"in Windows.'''## Author: Nikos Kouremenosimport gtkdef make_menu(event_button, event_time, icon):    menu = gtk.Menu()    item = gtk.MenuItem('hi')    item.show()    menu.append(item)    menu.popup(None, None,        gtk.status_icon_position_menu, event_button,        event_time, icon)def on_right_click(icon, event_button, event_time):    make_menu(event_button, event_time, icon)def StatusIconDemo(parent=None):    icon = gtk.status_icon_new_from_stock(gtk.STOCK_QUIT)    icon.connect('popup-menu', on_right_click)if __name__ == '__main__':    StatusIconDemo()    gtk.main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?