Python gi.repository.Gtk.CheckMenuItem() Examples
The following are 22
code examples of gi.repository.Gtk.CheckMenuItem().
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
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: campaign_selection.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_popup_filter_menu(self): # create filter menu and menuitems filter_menu = Gtk.Menu() menu_item_expired = Gtk.CheckMenuItem('Expired campaigns') menu_item_user = Gtk.CheckMenuItem('Your campaigns') menu_item_other = Gtk.CheckMenuItem('Other campaigns') self.filter_menu_items = { 'expired_campaigns': menu_item_expired, 'your_campaigns': menu_item_user, 'other_campaigns': menu_item_other } # set up the menuitems and add it to the menubutton for menus in self.filter_menu_items: filter_menu.append(self.filter_menu_items[menus]) self.filter_menu_items[menus].connect('toggled', self.signal_checkbutton_toggled) self.filter_menu_items[menus].show() self.filter_menu_items['expired_campaigns'].set_active(self.config['filter.campaign.expired']) self.filter_menu_items['your_campaigns'].set_active(self.config['filter.campaign.user']) self.filter_menu_items['other_campaigns'].set_active(self.config['filter.campaign.other_users']) self.gobjects['menubutton_filter'].set_popup(filter_menu) filter_menu.connect('destroy', self._save_filter)
Example #2
Source File: gui.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def on_populate_popup(self, o, menu): sep = Gtk.SeparatorMenuItem() menu.append(sep) item = Gtk.CheckMenuItem(_('Show Tasks as Flat List')) # T: Checkbox in task list - hides parent items item.set_active(self.uistate['show_flatlist']) item.connect('toggled', self.on_show_flatlist_toggle) item.show_all() menu.append(item) item = Gtk.CheckMenuItem(_('Only Show Active Tasks')) # T: Checkbox in task list - this options hides tasks that are not yet started item.set_active(self.uistate['only_show_act']) item.connect('toggled', self.on_show_active_toggle) item.show_all() menu.append(item)
Example #3
Source File: tags.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def on_populate_popup(self, treeview, menu): # Add a popup menu item to switch the treeview mode populate_popup_add_separator(menu, prepend=True) item = Gtk.CheckMenuItem(_('Show full page name')) # T: menu option item.set_active(self.uistate['show_full_page_name']) item.connect_object('toggled', self.__class__.toggle_show_full_page_name, self) menu.prepend(item) item = Gtk.CheckMenuItem(_('Sort pages by tags')) # T: menu option item.set_active(self.uistate['treeview'] == 'tags') item.connect_object('toggled', self.__class__.toggle_treeview, self) model = self.treeview.get_model() if isinstance(model, TaggedPageTreeStore): item.set_sensitive(False) # with tag selection toggle does nothing menu.prepend(item) menu.show_all()
Example #4
Source File: backend_gtk3.py From Computable with MIT License | 5 votes |
def _make_axis_menu(self): # called by self._update*() def toggled(item, data=None): if item == self.itemAll: for item in items: item.set_active(True) elif item == self.itemInvert: for item in items: item.set_active(not item.get_active()) ind = [i for i,item in enumerate(items) if item.get_active()] self.set_active(ind) menu = Gtk.Menu() self.itemAll = Gtk.MenuItem("All") menu.append(self.itemAll) self.itemAll.connect("activate", toggled) self.itemInvert = Gtk.MenuItem("Invert") menu.append(self.itemInvert) self.itemInvert.connect("activate", toggled) items = [] for i in range(len(self._axes)): item = Gtk.CheckMenuItem("Axis %d" % (i+1)) menu.append(item) item.connect("toggled", toggled) item.set_active(True) items.append(item) menu.show_all() return menu
Example #5
Source File: sourceview.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def on_populate_popup(self, view, menu): menu.prepend(Gtk.SeparatorMenuItem()) def activate_linenumbers(item): self.buffer.set_show_line_numbers(item.get_active()) item = Gtk.CheckMenuItem(_('Show Line Numbers')) # T: preference option for sourceview plugin item.set_active(self.buffer.object_attrib['linenumbers']) item.set_sensitive(self.view.get_editable()) item.connect_after('activate', activate_linenumbers) menu.prepend(item) def activate_lang(item): self.buffer.set_language(item.zim_sourceview_languageid) item = Gtk.MenuItem.new_with_mnemonic(_('Syntax')) item.set_sensitive(self.view.get_editable()) submenu = Gtk.Menu() for lang in sorted(LANGUAGES, key=lambda k: k.lower()): langitem = Gtk.MenuItem.new_with_mnemonic(lang) langitem.connect('activate', activate_lang) langitem.zim_sourceview_languageid = LANGUAGES[lang] submenu.append(langitem) item.set_submenu(submenu) menu.prepend(item) menu.show_all()
Example #6
Source File: bookmarksbar.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def do_plus_button_popup_menu(self, button, event): '''Handler for button-release-event, triggers popup menu for plus button.''' if event.button == 3: menu = Gtk.Menu() item = Gtk.CheckMenuItem(_('Show full Page Name')) # T: menu item for context menu item.set_active(self.uistate['show_full_page_name']) item.connect('activate', lambda o: self.toggle_show_full_page_name()) menu.append(item) menu.show_all() gtk_popup_at_pointer(menu) return True
Example #7
Source File: tags.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def do_populate_popup(self, menu): populate_popup_add_separator(menu, prepend=True) item = Gtk.CheckMenuItem(_('Sort alphabetically')) # T: Context menu item for tag cloud item.set_active(self._alphabetically) item.connect('toggled', self._switch_sorting) item.show_all() menu.prepend(item)
Example #8
Source File: main_button_menu.py From bokken with GNU General Public License v2.0 | 5 votes |
def create_view_menu(self): self.nb = self.main.tviews.right_notebook for x in self.nb.get_children(): box = self.nb.get_tab_label(x) element = box.get_children()[1].get_text().lower() item = Gtk.CheckMenuItem("Show " + element) if element != 'full info': item.set_active(True) item.connect("activate", self._on_status_view) self.vmenu.append(item) self.vmenu.show_all()
Example #9
Source File: gremlin3dwidget.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_gremlin_clicked(self, widget, event, data=None): if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS: self.clear_live_plotter() # Settings if event.type == Gdk.EventType.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 #10
Source File: talk_time.py From pympress with GNU General Public License v2.0 | 5 votes |
def switch_pause(self, widget, event = None): """ Switch the timer between paused mode and running (normal) mode. Returns: `bool`: whether the clock's pause was toggled. """ if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.paused: return False if self.paused: self.unpause() else: self.pause() return None
Example #11
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def switch_annotations(self, widget, event = None): """ Switch the display to show annotations or to hide them. Returns: `bool`: whether the mode has been toggled. """ if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.show_annotations: return False self.show_annotations = not self.show_annotations self.p_frame_annot.set_visible(self.show_annotations) self.config.set('presenter', 'show_annotations', 'on' if self.show_annotations else 'off') if self.show_annotations: parent = self.p_frame_annot.get_parent() if issubclass(type(parent), Gtk.Paned): if parent.get_orientation() == Gtk.Orientation.HORIZONTAL: size = parent.get_parent().get_allocated_width() else: size = parent.get_parent().get_allocated_height() parent.set_position(self.pane_handle_pos[parent] * size) self.annotations.add_annotations(self.doc.current_page().get_annotations()) self.pres_annot.set_active(self.show_annotations) return True
Example #12
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def change_notes_pos(self, widget, event = None, force_change = False): """ Switch the position of the nodes in the slide. Returns: `bool`: whether the mode has been toggled. """ if issubclass(type(widget), Gtk.CheckMenuItem): # if this widget is not the active one do nothing if not widget.get_active(): return False target_mode = document.PdfPage[widget.get_name()[len('notes_'):].upper()] elif issubclass(type(widget), document.PdfPage): target_mode = widget else: return False # Redundant toggle, do nothing if target_mode == self.chosen_notes_mode: return False # Update the choice, except for NONE if target_mode: self.chosen_notes_mode = target_mode self.get_object('notes_' + target_mode.name.lower()).set_active(True) self.config.set('notes position', target_mode.direction(), target_mode.name.lower()) # Change the notes arrangement if they are enabled or if we are forced to if self.notes_mode or force_change: self.switch_mode('changed notes position', target_mode = target_mode) return True
Example #13
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def switch_blanked(self, widget, event = None): """ Switch the blanked mode of the content screen. Returns: `bool`: whether the mode has been toggled. """ if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.blanked: return False self.blanked = not self.blanked self.c_da.queue_draw() self.pres_blank.set_active(self.blanked) return True
Example #14
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def switch_fullscreen(self, widget): """ Switch the Content window to fullscreen (if in normal mode) or to normal mode (if fullscreen). Screensaver will be disabled when entering fullscreen mode, and enabled when leaving fullscreen mode. Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred Returns: `bool`: whether some window's full screen status got toggled """ if isinstance(widget, Gtk.CheckMenuItem): # Called from menu -> use c_win toggle_to = widget.get_active() widget = self.c_win else: toggle_to = None if widget != self.c_win and widget != self.p_win: logger.error(_("Unknow widget {} to be fullscreened, aborting.").format(widget)) return False cur_state = (widget.get_window().get_state() & Gdk.WindowState.FULLSCREEN) if cur_state == toggle_to: return elif cur_state: widget.unfullscreen() else: widget.fullscreen() if widget == self.c_win: self.pres_fullscreen.set_active(not cur_state) return True
Example #15
Source File: graphview.py From addons-source with GNU General Public License v2.0 | 5 votes |
def update_setting(self, menu_item, constant): """ Save changed setting. menu_item should be Gtk.CheckMenuItem. """ self.view._config.set(constant, menu_item.get_active())
Example #16
Source File: backend_gtk3.py From matplotlib-4-abaqus with MIT License | 5 votes |
def _make_axis_menu(self): # called by self._update*() def toggled(item, data=None): if item == self.itemAll: for item in items: item.set_active(True) elif item == self.itemInvert: for item in items: item.set_active(not item.get_active()) ind = [i for i,item in enumerate(items) if item.get_active()] self.set_active(ind) menu = Gtk.Menu() self.itemAll = Gtk.MenuItem("All") menu.append(self.itemAll) self.itemAll.connect("activate", toggled) self.itemInvert = Gtk.MenuItem("Invert") menu.append(self.itemInvert) self.itemInvert.connect("activate", toggled) items = [] for i in range(len(self._axes)): item = Gtk.CheckMenuItem("Axis %d" % (i+1)) menu.append(item) item.connect("toggled", toggled) item.set_active(True) items.append(item) menu.show_all() return menu
Example #17
Source File: editable_label.py From pympress with GNU General Public License v2.0 | 4 votes |
def on_label_event(self, widget, event = None, name = None): """ Manage events on the current slide label/entry. This function triggers replacing the label with an entry when clicked or otherwise toggled. Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred event (:class:`~Gtk.Event` or None): the event that occurred, None if tf we called from a menu item name (`str`): name of the key in the casae of a key press Returns: `bool`: whether the event was consumed """ hint = None if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.editing: # Checking the checkbox conforming to current situation: do nothing return False elif issubclass(type(widget), Gtk.MenuItem): # A button or menu item, etc. directly connected to this action hint = widget.get_name() pass elif event.type == Gdk.EventType.BUTTON_PRESS: # If we clicked on the Event Box then don't toggle, just enable. if widget is not self.event_box or self.editing: return False elif event.type == Gdk.EventType.KEY_PRESS: hint = name else: return False # Perform the state toggle if not self.editing: self.swap_label_for_entry(hint) else: self.restore_label() return True
Example #18
Source File: ui.py From pympress with GNU General Public License v2.0 | 4 votes |
def switch_mode(self, widget, event = None, target_mode = None): """ Switch the display mode to "Notes mode" or "Normal mode" (without notes). Returns: `bool`: whether the mode has been toggled. """ if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == bool(self.notes_mode): # We toggle the menu item which brings us here, but it is somehow already in sync with notes mode. # Exit to not risk double-toggling. Button is now in sync and can be toggled again correctly. return False if target_mode is None: target_mode = document.PdfPage.NONE if self.notes_mode else self.chosen_notes_mode if target_mode == self.notes_mode: return False self.scribbler.disable_scribbling() if target_mode and not self.notes_mode: self.swap_layout('plain', 'notes') elif not target_mode and self.notes_mode: self.swap_layout('notes', 'plain') self.notes_mode = target_mode page_type = self.notes_mode.complement() self.cache.set_widget_type('c_da', page_type) self.cache.set_widget_type('c_da_zoomed', page_type) self.cache.set_widget_type('p_da_next', page_type) self.cache.set_widget_type('p_da_cur', page_type) self.cache.set_widget_type('p_da_cur_zoomed', page_type) self.cache.set_widget_type('scribble_p_da', page_type) self.cache.set_widget_type('p_da_notes', self.notes_mode) if self.notes_mode: self.cache.enable_prerender('p_da_notes') self.cache.disable_prerender('p_da_cur') else: self.cache.disable_prerender('p_da_notes') self.cache.enable_prerender('p_da_cur') self.medias.adjust_margins_for_mode(page_type) self.on_page_change(False) self.pres_notes.set_active(self.notes_mode) return True
Example #19
Source File: ThumbsManager.py From variety with GNU General Public License v3.0 | 4 votes |
def create_rating_menu(file, main_window): def _set_rating_maker(rating): def _set_rating(widget, rating=rating): try: Util.set_rating(file, rating) main_window.on_rating_changed(file) except Exception: logger.exception(lambda: "Could not set EXIF rating") main_window.show_notification(_("Could not set EXIF rating")) return _set_rating try: actual_rating = Util.get_rating(file) except Exception: actual_rating = None rating_menu = Gtk.Menu() for rating in range(5, 0, -1): item = Gtk.CheckMenuItem("\u2605" * rating) item.set_draw_as_radio(True) item.set_active(actual_rating == rating) item.set_sensitive(not item.get_active()) item.connect("activate", _set_rating_maker(rating)) rating_menu.append(item) rating_menu.append(Gtk.SeparatorMenuItem.new()) unrated_item = Gtk.CheckMenuItem(_("Unrated")) unrated_item.set_draw_as_radio(True) unrated_item.set_active(actual_rating is None or actual_rating == 0) unrated_item.set_sensitive(not unrated_item.get_active()) unrated_item.connect("activate", _set_rating_maker(None)) rating_menu.append(unrated_item) rejected_item = Gtk.CheckMenuItem(_("Rejected")) rejected_item.set_draw_as_radio(True) rejected_item.set_active(actual_rating is not None and actual_rating < 0) rejected_item.set_sensitive(not rejected_item.get_active()) rejected_item.connect("activate", _set_rating_maker(-1)) rating_menu.append(rejected_item) rating_menu.show_all() return rating_menu
Example #20
Source File: notifier.py From autokey with GNU General Public License v3.0 | 4 votes |
def rebuild_menu(self): # Main Menu items self.errorItem = Gtk.MenuItem(_("View script error")) enableMenuItem = Gtk.CheckMenuItem(_("Enable Expansions")) enableMenuItem.set_active(self.app.service.is_running()) enableMenuItem.set_sensitive(not self.app.serviceDisabled) configureMenuItem = Gtk.ImageMenuItem(_("Show Main Window")) configureMenuItem.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU)) removeMenuItem = Gtk.ImageMenuItem(_("Remove icon")) removeMenuItem.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)) quitMenuItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, None) # Menu signals enableMenuItem.connect("toggled", self.on_enable_toggled) configureMenuItem.connect("activate", self.on_show_configure) removeMenuItem.connect("activate", self.on_remove_icon) quitMenuItem.connect("activate", self.on_destroy_and_exit) self.errorItem.connect("activate", self.on_show_error) # Get phrase folders to add to main menu folders = [] items = [] for folder in self.configManager.allFolders: if folder.show_in_tray_menu: folders.append(folder) for item in self.configManager.allItems: if item.show_in_tray_menu: items.append(item) # Construct main menu self.menu = popupmenu.PopupMenu(self.app.service, folders, items, False) if len(items) > 0: self.menu.append(Gtk.SeparatorMenuItem()) self.menu.append(self.errorItem) self.menu.append(enableMenuItem) self.menu.append(configureMenuItem) self.menu.append(removeMenuItem) self.menu.append(quitMenuItem) self.menu.show_all() self.errorItem.hide() self.indicator.set_menu(self.menu)
Example #21
Source File: app.py From syncthing-gtk with GNU General Public License v2.0 | 4 votes |
def setup_widgets(self): self.builder = UIBuilder() # Set conditions for UIBuilder old_gtk = ((Gtk.get_major_version(), Gtk.get_minor_version()) < (3, 12)) and not IS_WINDOWS icons_in_menu = self.config["icons_in_menu"] if self.use_headerbar: self.builder.enable_condition("header_bar") if not self.use_headerbar: self.builder.enable_condition("traditional_header") if IS_WINDOWS: self.builder.enable_condition("is_windows") if IS_GNOME: self.builder.enable_condition("is_gnome") if old_gtk: self.builder.enable_condition("old_gtk") if icons_in_menu: self.builder.enable_condition("icons_in_menu") # Fix icon path self.builder.replace_icon_path("icons/", self.iconpath) # Load glade file self.builder.add_from_file(os.path.join(self.gladepath, "app.glade")) self.builder.connect_signals(self) # Dunno how to do this from glade if self.use_headerbar and IS_GNOME: self.set_app_menu(self["app-menu"]) # Create speedlimit submenus for incoming and outcoming speeds L_MEH = [("menu-si-sendlimit", self.cb_menu_sendlimit), ("menu-si-recvlimit", self.cb_menu_recvlimit)] for limitmenu, eventhandler in L_MEH: submenu = self["%s-sub" % (limitmenu,)] for speed in SPEED_LIMIT_VALUES: menuitem = Gtk.CheckMenuItem(_("%s kB/s") % (speed,)) item_id = "%s-%s" % (limitmenu, speed) menuitem.connect('activate', eventhandler, speed) self[item_id] = menuitem submenu.add(menuitem) self[limitmenu].show_all() if not old_gtk: if not self["edit-menu-icon"] is None: if not Gtk.IconTheme.get_default().has_icon(self["edit-menu-icon"].get_icon_name()[0]): # If requested icon is not found in default theme, replace it with emblem-system-symbolic self["edit-menu-icon"].set_from_icon_name("emblem-system-symbolic", self["edit-menu-icon"].get_icon_name()[1]) # Set window title in way that even Gnome can understand icon = os.path.join(self.iconpath, "syncthing-gtk.png") self["window"].set_title(_("Syncthing-GTK")) self["window"].set_wmclass("Syncthing GTK", "Syncthing GTK") if os.path.exists(icon): self["window"].set_icon(GdkPixbuf.Pixbuf.new_from_file(icon)) self.add_window(self["window"])
Example #22
Source File: __init__.py From pychess with GNU General Public License v3.0 | 4 votes |
def __init__(self, name, label): self.name = name self.label = label self.default = False self.widget = Gtk.Alignment() self.widget.show() self.toolbuttons = [] self.menuitems = [] self.docks = {} self.main_notebook = None if getattr(sys, 'frozen', False) and not MSYS2: zip_path = os.path.join(os.path.dirname(sys.executable), "library.zip") importer = zipimport.zipimporter(zip_path + "/pychess/perspectives/%s" % name) postfix = "Panel.pyc" with zipfile.ZipFile(zip_path, 'r') as myzip: names = [f[:-4].split("/")[-1] for f in myzip.namelist() if f.endswith(postfix) and "/%s/" % name in f] self.sidePanels = [importer.load_module(name) for name in names] else: path = "%s/%s" % (os.path.dirname(__file__), name) ext = ".pyc" if getattr(sys, 'frozen', False) and MSYS2 else ".py" postfix = "Panel%s" % ext files = [f[:-len(ext)] for f in os.listdir(path) if f.endswith(postfix)] self.sidePanels = [importlib.import_module("pychess.perspectives.%s.%s" % (name, f)) for f in files] for panel in self.sidePanels: close_button = Gtk.Button() close_button.set_property("can-focus", False) close_button.add(createImage(gtk_close)) close_button.set_relief(Gtk.ReliefStyle.NONE) close_button.set_size_request(20, 18) close_button.connect("clicked", self.on_clicked, panel) menu_item = Gtk.CheckMenuItem(label=panel.__title__) menu_item.name = panel_name(panel.__name__) # if menu_item.name != "LecturesPanel": # menu_item.set_active(True) menu_item.connect("toggled", self.on_toggled, panel) self.menuitems.append(menu_item) panel.menu_item = menu_item box = dock_panel_tab(panel.__title__, panel.__desc__, panel.__icon__, close_button) self.docks[panel_name(panel.__name__)] = [box, None, menu_item]