本文整理汇总了Python中gi.repository.Gtk.STOCK_QUIT属性的典型用法代码示例。如果您正苦于以下问题:Python Gtk.STOCK_QUIT属性的具体用法?Python Gtk.STOCK_QUIT怎么用?Python Gtk.STOCK_QUIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.STOCK_QUIT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_QUIT [as 别名]
def _setup_menu(self):
mute_menu_item = Gtk.ImageMenuItem("Mute")
img = Gtk.Image.new_from_icon_name(
"audio-volume-muted", Gtk.IconSize.SMALL_TOOLBAR
)
mute_menu_item.set_image(img)
mute_menu_item.connect("activate", self._cb_menu_mute)
mixer_menu_item = Gtk.ImageMenuItem("Mixer")
img = Gtk.Image.new_from_icon_name(
"multimedia-volume-control", Gtk.IconSize.SMALL_TOOLBAR
)
mixer_menu_item.set_image(img)
mixer_menu_item.connect("activate", self._cb_menu_mixer)
preferences_menu_item = Gtk.ImageMenuItem("Preferences")
img = Gtk.Image.new_from_icon_name(
"preferences-desktop", Gtk.IconSize.SMALL_TOOLBAR
)
preferences_menu_item.set_image(img)
preferences_menu_item.connect("activate", self._cb_menu_preferences)
about_menu_item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT)
about_menu_item.connect("activate", self._cb_menu_about)
exit_menu_item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT)
exit_menu_item.connect("activate", self._cb_menu_quit)
self._menu.append(mute_menu_item)
self._menu.append(mixer_menu_item)
self._menu.append(preferences_menu_item)
self._menu.append(Gtk.SeparatorMenuItem())
self._menu.append(about_menu_item)
self._menu.append(exit_menu_item)
self._menu.show_all()
# gui callbacks
示例2: create_toolbuttons
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_QUIT [as 别名]
def create_toolbuttons(self):
def on_exit_clicked(button):
perspective_manager.disable_perspective("learn")
self.exit_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_QUIT)
self.exit_button.set_tooltip_text(_("Quit Learning"))
self.exit_button.set_label("exit")
self.exit_button.connect("clicked", on_exit_clicked)
示例3: on_tray_popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_QUIT [as 别名]
def on_tray_popup_menu(self, _status_icon, button, activate_time):
"""
Called when the user right-clicks the tray icon
"""
tray_menu_xml = """
<ui>
<popup action="TrayMenu">
<menuitem action="Show"/>
<menuitem action="Quit"/>
</popup>
</ui>"""
# Create an ActionGroup
actiongroup = Gtk.ActionGroup("TrayActionGroup")
# Create actions
actiongroup.add_actions(
[
(
"Show",
Gtk.STOCK_MEDIA_PLAY,
_("Show RedNotebook"),
None,
None,
lambda widget: self.show(),
),
("Quit", Gtk.STOCK_QUIT, None, None, None, self.on_quit_activate),
]
)
# Add the actiongroup to the uimanager
self.uimanager.insert_action_group(actiongroup, 0)
# Add a UI description
self.uimanager.add_ui_from_string(tray_menu_xml)
# Create a Menu
menu = self.uimanager.get_widget("/TrayMenu")
menu.popup(None, None, None, None, button, activate_time)
示例4: rebuild_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_QUIT [as 别名]
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)