本文整理汇总了Python中gi.repository.Gtk.CheckMenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.CheckMenuItem方法的具体用法?Python Gtk.CheckMenuItem怎么用?Python Gtk.CheckMenuItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.CheckMenuItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_popup_filter_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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)
示例2: on_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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()
示例3: on_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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)
示例4: _make_axis_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例5: update_setting
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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())
示例6: switch_fullscreen
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例7: switch_blanked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例8: change_notes_pos
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例9: switch_annotations
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例10: switch_pause
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例11: on_gremlin_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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()
示例12: create_view_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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()
示例13: do_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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)
示例14: do_plus_button_popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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
示例15: on_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CheckMenuItem [as 别名]
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()