本文整理汇总了Python中sugar3.graphics.menuitem.MenuItem.get_children方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.get_children方法的具体用法?Python MenuItem.get_children怎么用?Python MenuItem.get_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.get_children方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import get_children [as 别名]
def __init__(self):
Gtk.ComboBox.__init__(self)
ToolButton.__init__(self, icon_name='font-text',
tooltip=_('Select font'))
self.connect('clicked', self.__font_selection_cb)
context = self.get_pango_context()
self._init_font_list()
self._font_name = 'Sans'
font_names = []
for family in context.list_families():
name = family.get_name()
if name in self._font_white_list:
font_names.append(name)
for font_name in sorted(font_names):
menu_item = MenuItem(font_name)
markup = '<span font="%s">%s</span>' % (font_name, font_name)
menu_item.get_children()[0].set_markup(markup)
menu_item.connect('activate', self.__menu_activated, font_name)
self.props.palette.menu.append(menu_item)
menu_item.show()
self.show()
示例2: _reload_fonts
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import get_children [as 别名]
def _reload_fonts(self, monitor, gio_file, other_file, event):
if event != Gio.FileMonitorEvent.CHANGES_DONE_HINT:
return
self._font_white_list = []
self._font_white_list.extend(DEFAULT_FONTS)
fonts_file = open(USER_FONTS_FILE_PATH)
for line in fonts_file:
self._font_white_list.append(line.strip())
# update the menu
for child in self.props.palette.menu.get_children():
self.props.palette.menu.remove(child)
child = None
context = self.get_pango_context()
tmp_list = []
for family in context.list_families():
name = family.get_name()
if name in self._font_white_list:
tmp_list.append(name)
for font_name in sorted(tmp_list):
menu_item = MenuItem(font_name)
markup = '<span font="%s">%s</span>' % (font_name, font_name)
menu_item.get_children()[0].set_markup(markup)
menu_item.connect('activate', self.__menu_activated, font_name)
self.props.palette.menu.append(menu_item)
menu_item.show()
return False