Python gtk.Menu() Examples
The following are 29
code examples of gtk.Menu().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gtk
, or try the search function
.
Example #1
Source File: gtkbase.py From gui-o-matic with GNU Lesser General Public License v3.0 | 6 votes |
def _add_menu_item(self, id=None, label='Menu item', sensitive=False, separator=False, op=None, args=None, **ignored_kwarg): if separator: menu_item = gtk.SeparatorMenuItem() else: menu_item = gtk.MenuItem(label) menu_item.set_sensitive(sensitive) if op: def activate(o, a): return lambda d: self._do(o, a) menu_item.connect("activate", activate(op, args or [])) menu_item.show() self.menu.append(menu_item) if id: self.items[id] = menu_item
Example #2
Source File: operations.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 6 votes |
def _init_gui(self): if self._add_operation_text is not None: self._button_add = gtk.Button() button_hbox = gtk.HBox() button_hbox.set_spacing(self._ADD_BUTTON_HBOX_SPACING) button_hbox.pack_start( gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU), expand=False, fill=False) label_add = gtk.Label(self._add_operation_text.encode(pg.GTK_CHARACTER_ENCODING)) label_add.set_use_underline(True) button_hbox.pack_start(label_add, expand=False, fill=False) self._button_add.add(button_hbox) else: self._button_add = gtk.Button(stock=gtk.STOCK_ADD) self._button_add.set_relief(gtk.RELIEF_NONE) self._button_add.connect("clicked", self._on_button_add_clicked) self._vbox.pack_start(self._button_add, expand=False, fill=False) self._operations_menu = gtk.Menu() self._init_operations_menu_popup()
Example #3
Source File: preview_name.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 6 votes |
def _init_tags_menu(self): self._tags_menu_items = {} self._tags_remove_submenu_items = {} self._tags_menu_relative_position = None self._tags_menu = gtk.Menu() self._tags_remove_submenu = gtk.Menu() self._tags_menu.append(gtk.SeparatorMenuItem()) self._menu_item_add_tag = gtk.MenuItem(_("Add New Tag...")) self._menu_item_add_tag.connect("activate", self._on_menu_item_add_tag_activate) self._tags_menu.append(self._menu_item_add_tag) self._menu_item_remove_tag = gtk.MenuItem(_("Remove Tag")) self._menu_item_remove_tag.set_submenu(self._tags_remove_submenu) self._tags_menu.append(self._menu_item_remove_tag) for tag, tag_display_name in self._available_tags_setting.default_value.items(): self._add_tag_menu_item(tag, tag_display_name) self._tags_menu.show_all()
Example #4
Source File: menubuilder.py From nightmare with GNU General Public License v2.0 | 5 votes |
def addField(self, pathstr, callback=None, args=(), stockid=None): parent = self.menu kid = None plist = pathstr.split(self.splitchar) for p in plist[:-1]: kid = parent.kids.get(p) if kid == None: item = gtk.MenuItem(p, True) item.set_name("vwidget_menu") item.show() parent.insert(item, parent.idx) parent.idx += 1 kid = Menu() kid.idx = 0 item.set_submenu(kid) parent.kids[p] = kid parent = kid if stockid != None: item = gtk.ImageMenuItem(stock_id=stockid) else: item = gtk.MenuItem(plist[-1], True) if callback != None: item.connect("activate", callback, *args) item.show() item.set_name("vwidget_menu") parent.insert(item, parent.idx) parent.idx += 1 #parent.append(item) return item
Example #5
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 5 votes |
def get_folder_menu(self, obj, folder, path): if not obj or not (isinstance(obj,gtk.Menu) or isinstance(obj,gtk.MenuItem)): return None for item in obj.get_children(): if path == folder+'/'+item.get_label(): return item.get_submenu() i = self.get_folder_menu(item.get_submenu(), folder+'/'+item.get_label(), path) if i: return i
Example #6
Source File: gtkbase.py From gui-o-matic with GNU Lesser General Public License v3.0 | 5 votes |
def _menu_setup(self): self.items = {} self.menu = gtk.Menu() self._create_menu_from_config()
Example #7
Source File: goagent-gtk.py From arkc-client with GNU General Public License v2.0 | 5 votes |
def make_menu(self): menu = gtk.Menu() itemlist = [(u'\u663e\u793a', self.on_show), (u'\u9690\u85cf', self.on_hide), (u'\u505c\u6b62', self.on_stop), (u'\u91cd\u65b0\u8f7d\u5165', self.on_reload), (u'\u9000\u51fa', self.on_quit)] for text, callback in itemlist: item = gtk.MenuItem(text) item.connect('activate', callback) item.show() menu.append(item) menu.show() return menu
Example #8
Source File: core.py From Tocino with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #9
Source File: core.py From ns3-802.11ad with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #10
Source File: hazzygremlin.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_gremlin_clicked(self, widget, event, data=None): if event.type == gtk.gdk._2BUTTON_PRESS: self.clear_live_plotter() # Settings if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: menu = gtk.Menu() program_alpha = gtk.CheckMenuItem("Program alpha") program_alpha.set_active(self.program_alpha) program_alpha.connect("activate", self.toggle_program_alpha) menu.append(program_alpha) show_limits = gtk.CheckMenuItem("Show limits") show_limits.set_active(self.show_limits) show_limits.connect("activate", self.toggle_show_limits) menu.append(show_limits) show_extents = gtk.CheckMenuItem("Show extents") show_extents.set_active(self.show_extents_option) show_extents.connect("activate", self.toggle_show_extents_option) menu.append(show_extents) live_plot = gtk.CheckMenuItem("Show live plot") live_plot.set_active(self.show_live_plot) live_plot.connect("activate", self.toggle_show_live_plot) menu.append(live_plot) # lathe = gtk.CheckMenuItem("Lathe mode") # lathe.set_active(self.lathe_option ) # lathe.connect("activate", self.toggle_lathe_option) # menu.append(lathe) menu.popup(None, None, None, event.button, event.time) menu.show_all()
Example #11
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #12
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #13
Source File: tickeys_tray.py From Tickeys-linux with MIT License | 5 votes |
def make_menu(self): menu = gtk.Menu() itemlist = [(u'显示界面', self.on_show), (u'项目Github页', self.show_github_page), (u'退出', self.on_quit)] for text, callback in itemlist: item = gtk.MenuItem(text) item.connect('activate', callback) item.show() menu.append(item) menu.show() return menu
Example #14
Source File: core.py From ns-3-dev-git with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #15
Source File: core.py From royal-chaos with MIT License | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #16
Source File: core.py From ns3-rdma with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #17
Source File: core.py From 802.11ah-ns3 with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #18
Source File: core.py From ns3-load-balance with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #19
Source File: gtk_tray.py From oss-ftp with MIT License | 5 votes |
def make_menu(self): menu = gtk.Menu() itemlist = [(u'Config', self.on_show), ('Restart OSS-FTP', self.on_restart_ossftp), (u'Quit', self.on_quit)] for text, callback in itemlist: item = gtk.MenuItem(text) item.connect('activate', callback) item.show() menu.append(item) menu.show() return menu
Example #20
Source File: core.py From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #21
Source File: core.py From ntu-dsi-dcn with GNU General Public License v2.0 | 5 votes |
def popup_node_menu(self, node, event): menu = gtk.Menu() self.emit("populate-node-menu", node, menu) menu.popup(None, None, None, event.button, event.time)
Example #22
Source File: menubuilder.py From nightmare with GNU General Public License v2.0 | 5 votes |
def __init__(self): gtk.Menu.__init__(self) FieldAdder.__init__(self, self) self.set_name("vwidget_menu")
Example #23
Source File: custom_commands.py From NINJA-PingU with GNU General Public License v3.0 | 5 votes |
def callback(self, menuitems, menu, terminal): """Add our menu items to the menu""" item = gtk.MenuItem(_('Custom Commands')) menuitems.append(item) submenu = gtk.Menu() item.set_submenu(submenu) menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) menuitem.connect("activate", self.configure) submenu.append(menuitem) menuitem = gtk.SeparatorMenuItem() submenu.append(menuitem) theme = gtk.IconTheme() for command in self.cmd_list: if not command['enabled']: continue exe = command['command'].split(' ')[0] iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN) if iconinfo: image = gtk.Image() image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU) menuitem = gtk.ImageMenuItem(command['name']) menuitem.set_image(image) else: menuitem = gtk.MenuItem(command["name"]) menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] }) submenu.append(menuitem)
Example #24
Source File: status_icon_gtk2.py From sun with GNU General Public License v3.0 | 4 votes |
def sub_menu(self): """Create daemon submenu """ submenu = gtk.Menu() self.start = gtk.ImageMenuItem("Start") self.stop = gtk.ImageMenuItem("Stop") self.restart = gtk.ImageMenuItem("Restart") self.status = gtk.ImageMenuItem("Status") self.start.show() self.stop.show() self.restart.show() self.status.show() img_Start = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU) img_Start.show() self.start.set_image(img_Start) img_Stop = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) img_Stop.show() self.stop.set_image(img_Stop) img_Restart = gtk.image_new_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU) img_Restart.show() self.restart.set_image(img_Restart) img_Status = gtk.image_new_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_MENU) img_Status.show() self.status.set_image(img_Status) submenu.append(self.start) submenu.append(self.stop) submenu.append(self.restart) submenu.append(self.status) self.daemon = gtk.ImageMenuItem("Daemon") self.img_daemon = gtk.image_new_from_stock(self.daemon_STOCK, gtk.ICON_SIZE_MENU) self.img_daemon.show() self.daemon.set_submenu(submenu)
Example #25
Source File: status_icon_gtk2.py From sun with GNU General Public License v3.0 | 4 votes |
def menu(self, event_button, event_time, data=None): """Create popup menu """ self.sub_menu() menu = gtk.Menu() menu.append(self.daemon) separator = gtk.SeparatorMenuItem() menu_Check = gtk.ImageMenuItem("Check updates") img_Check = gtk.image_new_from_stock(gtk.STOCK_OK, gtk.ICON_SIZE_MENU) img_Check.show() menu_Info = gtk.ImageMenuItem("OS Info") img_Info = gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU) img_Info.show() menu_About = gtk.ImageMenuItem("About") img_About = gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU) img_About.show() self.daemon.set_image(self.img_daemon) menu.append(self.daemon) self.daemon.show() menu_Quit = gtk.ImageMenuItem("Quit") img_Quit = gtk.image_new_from_stock(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU) img_Quit.show() menu_Check.set_image(img_Check) menu_Info.set_image(img_Info) menu_About.set_image(img_About) menu_Quit.set_image(img_Quit) menu.append(menu_Check) menu.append(menu_Info) menu.append(separator) menu.append(menu_About) menu.append(menu_Quit) separator.show() menu_Check.show() menu_Info.show() menu_About.show() menu_Quit.show() menu_Check.connect_object("activate", self._Check, " ") menu_Info.connect_object("activate", self._Info, "OS Info") menu_About.connect_object("activate", self._About, "SUN") self.start.connect_object("activate", self._start, "Start daemon ") self.stop.connect_object("activate", self._stop, "Stop daemon ") self.restart.connect_object("activate", self._restart, "Restart daemon ") self.status.connect_object("activate", self._status, daemon_status()) menu_Quit.connect_object("activate", self._Quit, "stop") menu.popup(None, None, None, event_button, event_time, data)
Example #26
Source File: recipe-334779.py From code with MIT License | 4 votes |
def __init__(self): self.main_loop = gobject.MainLoop() # Create a window with a horizontal scale. self.wnd = gtk.Window() self.wnd.set_default_size(640, 480) self.wnd.set_title('Have fun with the transparency slider') hscale = gtk.HScale() hscale.set_digits(0) hscale.set_increments(1, 10) hscale.set_range(0, 100) hscale.set_value(100) hscale.connect('value_changed', self.set_window_alpha) self.wnd.add(hscale) # Note: gtk window must be realized before installing extensions. self.wnd.realize() self.wnd.show_all() self.win32ext = GTKWin32Ext(self.wnd) self.win32ext.add_notify_icon() # GTK menus from the notify icon! menu = gtk.Menu() menu_item = gtk.MenuItem('Baloons!') menu_item.connect_object('activate', self.menu_cb, self.wnd) menu.append(menu_item) menu_item = gtk.MenuItem('Fadeout Window') menu_item.connect('activate', self.fadeoutwindow) menu.append(menu_item) menu_item = gtk.MenuItem('Window Disappeared?') menu_item.connect('activate', self.fadeinwindow) menu.append(menu_item) menu.show_all() self.win32ext.notify_icon.menu = menu # Set up the callback messages self.win32ext.message_map({ WM_TRAYMESSAGE: self.on_notifyicon_activity })
Example #27
Source File: preview_image.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 4 votes |
def _init_gui(self): self._button_menu = gtk.Button() self._button_menu.set_relief(gtk.RELIEF_NONE) self._button_menu.add(gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN)) self._menu_item_update_automatically = gtk.CheckMenuItem( _("Update Preview Automatically")) self._menu_item_update_automatically.set_active(True) self._menu_settings = gtk.Menu() self._menu_settings.append(self._menu_item_update_automatically) self._menu_settings.show_all() self._button_refresh = gtk.Button() self._button_refresh.set_tooltip_text(_("Update Preview")) self._button_refresh.set_relief(gtk.RELIEF_NONE) self._button_refresh.add(gtk.image_new_from_pixbuf( self._button_refresh.render_icon(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU))) self._button_refresh.show_all() self._button_refresh.hide() self._button_refresh.set_no_show_all(True) self._hbox_buttons = gtk.HBox() self._hbox_buttons.pack_start(self._button_menu, expand=False, fill=False) self._hbox_buttons.pack_start(self._button_refresh, expand=False, fill=False) self._preview_image = gtk.Image() self._preview_image.set_no_show_all(True) self._placeholder_image = gtk.Image() self._placeholder_image.set_from_stock( gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG) self._placeholder_image.set_no_show_all(True) self._label_layer_name = gtk.Label() self._label_layer_name.set_ellipsize(pango.ELLIPSIZE_MIDDLE) self.set_spacing(self._WIDGET_SPACING) self.set_border_width(self._BORDER_WIDTH) self.pack_start(self._hbox_buttons, expand=False, fill=False) self.pack_start(self._preview_image, expand=True, fill=True) self.pack_start(self._placeholder_image, expand=True, fill=True) self.pack_start(self._label_layer_name, expand=False, fill=False) self._show_placeholder_image()
Example #28
Source File: __init__.py From nightmare with GNU General Public License v2.0 | 4 votes |
def vwGetPopup(self, textview, menu): va = self.selectva if va != None: pos = 0 # Breakpoints bm = gtk.MenuItem("Breakpoint") bm.connect("activate", self.popBreakpoint, va) menu.insert(bm, pos) pos += 1 rm = gtk.MenuItem("Run To Here") rm.connect("activate", self.popRunToHere, va) menu.insert(rm, pos) pos += 1 # Watchpoints wmenu = gtk.Menu() wm = gtk.MenuItem("Watch") wm.set_submenu(wmenu) wmread = gtk.MenuItem("Reads") wmread.connect("activate", self.popWatchRead, va) wmwrite = gtk.MenuItem("Writes") wmwrite.connect("activate", self.popWatchWrite, va) wmenu.append(wmread) wmenu.append(wmwrite) menu.insert(wm, pos) pos += 1 # Renderers rmenu = gtk.Menu() mn = gtk.MenuItem("Render") mn.set_submenu(rmenu) for name in self.vdbwin.db.canvas.getRendererNames(): i = gtk.MenuItem(name) i.connect("activate", self.reRender, name) rmenu.append(i) menu.insert(mn,pos) pos += 1 menu.show_all()
Example #29
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 4 votes |
def updateTree(self): for grupo in dict(groups): if len(groups[grupo])==0: del groups[grupo] if conf.COLLAPSED_FOLDERS == None: conf.COLLAPSED_FOLDERS = ','.join(self.get_collapsed_nodes()) self.menuServers.foreach(self.menuServers.remove) self.treeModel.clear() iconHost = self.treeServers.render_icon("gtk-network", size=gtk.ICON_SIZE_BUTTON, detail=None) iconDir = self.treeServers.render_icon("gtk-directory", size=gtk.ICON_SIZE_BUTTON, detail=None) grupos = groups.keys() grupos.sort(lambda x,y: cmp(y,x)) for grupo in grupos: group = None path = "" menuNode = self.menuServers for folder in grupo.split("/"): path = path + '/' + folder row = self.get_folder(self.treeModel, '', path) if row == None: group = self.treeModel.prepend(group, [folder, None, iconDir]) else: group = row.iter menu = self.get_folder_menu(self.menuServers, '', path) if menu == None: menu = gtk.ImageMenuItem(folder) #menu.set_image(gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_MENU)) menuNode.prepend(menu) menuNode = gtk.Menu() menu.set_submenu(menuNode) menu.show() else: menuNode = menu groups[grupo].sort(key=operator.attrgetter('name')) for host in groups[grupo]: self.treeModel.append(group, [host.name, host, iconHost]) mnuItem = gtk.ImageMenuItem(host.name) mnuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU)) mnuItem.show() mnuItem.connect("activate", lambda arg, nb, h: self.addTab(nb, h), self.nbConsole, host) menuNode.append(mnuItem) self.set_collapsed_nodes() conf.COLLAPSED_FOLDERS = None