本文整理匯總了Python中sugar.graphics.menuitem.MenuItem.get_children方法的典型用法代碼示例。如果您正苦於以下問題:Python MenuItem.get_children方法的具體用法?Python MenuItem.get_children怎麽用?Python MenuItem.get_children使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sugar.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.get_children方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: BuddyMenu
# 需要導入模塊: from sugar.graphics.menuitem import MenuItem [as 別名]
# 或者: from sugar.graphics.menuitem.MenuItem import get_children [as 別名]
#.........這裏部分代碼省略.........
home_model = shell.get_model()
self._active_activity_changed_hid = home_model.connect(
'active-activity-changed', self._cur_activity_changed_cb)
activity = home_model.get_active_activity()
self._update_invite_menu(activity)
def _add_my_items(self):
item = MenuItem(_('Shutdown'), 'system-shutdown')
item.connect('activate', self.__shutdown_activate_cb)
self.menu.append(item)
item.show()
client = gconf.client_get_default()
if client.get_bool('/desktop/sugar/show_restart'):
item = MenuItem(_('Restart'), 'system-restart')
item.connect('activate', self.__reboot_activate_cb)
self.menu.append(item)
item.show()
if client.get_bool('/desktop/sugar/show_logout'):
item = MenuItem(_('Logout'), 'system-logout')
item.connect('activate', self.__logout_activate_cb)
self.menu.append(item)
item.show()
item = MenuItem(_('My Settings'), 'preferences-system')
item.connect('activate', self.__controlpanel_activate_cb)
self.menu.append(item)
item.show()
def _quit(self, action):
home_window = jarabe.desktop.homewindow.get_instance()
home_window.busy_during_delayed_action(action)
def __logout_activate_cb(self, menu_item):
self._quit(get_session_manager().logout)
def __reboot_activate_cb(self, menu_item):
self._quit(get_session_manager().reboot)
def __shutdown_activate_cb(self, menu_item):
self._quit(get_session_manager().shutdown)
def __controlpanel_activate_cb(self, menu_item):
panel = ControlPanel()
panel.set_transient_for(self.get_toplevel())
panel.show()
def _update_invite_menu(self, activity):
buddy_activity = self._buddy.props.current_activity
if buddy_activity is not None:
buddy_activity_id = buddy_activity.activity_id
else:
buddy_activity_id = None
if activity is None or activity.is_journal() or \
activity.get_activity_id() == buddy_activity_id:
self._invite_menu.hide()
else:
title = activity.get_title()
label = self._invite_menu.get_children()[0]
label.set_text(_('Invite to %s') % title)
icon = Icon(file=activity.get_icon_path())
icon.props.xo_color = activity.get_icon_color()
self._invite_menu.set_image(icon)
icon.show()
self._invite_menu.show()
def _cur_activity_changed_cb(self, home_model, activity_model):
self._update_invite_menu(activity_model)
def __buddy_notify_nick_cb(self, buddy, pspec):
self.set_primary_text(glib.markup_escape_text(buddy.props.nick))
def _make_friend_cb(self, menuitem):
friends.get_model().make_friend(self._buddy)
def _remove_friend_cb(self, menuitem):
friends.get_model().remove(self._buddy)
def _invite_friend_cb(self, menuitem):
activity = shell.get_model().get_active_activity()
service = activity.get_service()
if service:
try:
service.InviteContact(self._buddy.props.account,
self._buddy.props.contact_id)
except dbus.DBusException, e:
expected_exceptions = [
'org.freedesktop.DBus.Error.UnknownMethod',
'org.freedesktop.DBus.Python.NotImplementedError']
if e.get_dbus_name() in expected_exceptions:
logging.warning('Trying deprecated Activity.Invite')
service.Invite(self._buddy.props.key)
else:
raise
else: