我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用gtk.status_icon_position_menu()。
def gtk_trayicon(self, logo_filename): trayicon = gtk.StatusIcon() trayicon.set_from_file(logo_filename) trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon)) trayicon.connect('activate', self.show_control_web) trayicon.set_tooltip('XX-Net') trayicon.set_visible(True) return trayicon
def show_menu(self, widget, event_button, event_time, menu): menu.popup(None, None, gtk.status_icon_position_menu, event_button, event_time, self.tray )
def _showTrayIconMenu(self, event_button, event_time, icon): menu = gtk.Menu() if not self.get_property('visible'): showItem = gtk.MenuItem('Show main window') showItem.connect('activate', self._trayIconClick) showItem.show() menu.append(showItem) item = gtk.MenuItem('Quit') item.connect('activate', gtk.main_quit) item.show() menu.append(item) menu.popup(None, None, gtk.status_icon_position_menu, event_button,event_time, icon)
def __init__(self, window, terminal): self.window = window self.window.set_size_request(652, 447) self.window.set_position(gtk.WIN_POS_CENTER) self.window.connect('delete-event',self.delete_event) self.terminal = terminal for cmd in ('python2.7', 'python27', 'python2'): if os.system('which %s' % cmd) == 0: self.command[1] = cmd break self.window.add(terminal) self.childpid = self.terminal.fork_command(self.command[0], self.command, os.getcwd()) if self.childpid > 0: self.childexited = self.terminal.connect('child-exited', self.on_child_exited) self.window.connect('delete-event', lambda w, e: gtk.main_quit()) else: self.childexited = None spawn_later(0.5, self.show_startup_notify) if should_visible(): self.window.show_all() logo_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'goagent-logo.png') if not os.path.isfile(logo_filename): with open(logo_filename, 'wb') as fp: fp.write(base64.b64decode(GOAGENT_LOGO_DATA)) self.window.set_icon_from_file(logo_filename) if appindicator: self.trayicon = appindicator.Indicator('GoAgent', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.trayicon.set_status(appindicator.STATUS_ACTIVE) self.trayicon.set_attention_icon('indicator-messages-new') self.trayicon.set_icon(logo_filename) self.trayicon.set_menu(self.make_menu()) else: self.trayicon = gtk.StatusIcon() self.trayicon.set_from_file(logo_filename) self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon)) self.trayicon.connect('activate', self.show_hide_toggle) self.trayicon.set_tooltip('GoAgent') self.trayicon.set_visible(True)
def __init__(self, window, terminal): self.window = window self.window.set_size_request(652, 447) self.window.set_position(gtk.WIN_POS_CENTER) self.window.connect('delete-event',self.delete_event) self.terminal = terminal for cmd in ('python2.7', 'python27', 'python2'): if os.system('which %s' % cmd) == 0: self.command[1] = cmd break self.window.add(terminal) self.childpid = self.terminal.fork_command(self.command[0], self.command, os.getcwd()) if self.childpid > 0: self.childexited = self.terminal.connect('child-exited', self.on_child_exited) self.window.connect('delete-event', lambda w, e: gtk.main_quit()) else: self.childexited = None spawn_later(0.5, self.show_startup_notify) if should_visible(): self.window.show_all() logo_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'goagent-logo.png') if not os.path.isfile(logo_filename): with open(logo_filename, 'wb') as fp: fp.write(base64.b64decode(GOAGENT_LOGO_DATA)) self.window.set_icon_from_file(logo_filename) if appindicator: self.trayicon = appindicator.Indicator('XX-Mini', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.trayicon.set_status(appindicator.STATUS_ACTIVE) self.trayicon.set_attention_icon('indicator-messages-new') self.trayicon.set_icon(logo_filename) self.trayicon.set_menu(self.make_menu()) else: self.trayicon = gtk.StatusIcon() self.trayicon.set_from_file(logo_filename) self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon)) self.trayicon.connect('activate', self.show_hide_toggle) self.trayicon.set_tooltip('XX-Mini') self.trayicon.set_visible(True)