本文整理汇总了Python中sugar3.graphics.menuitem.MenuItem.set_label方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.set_label方法的具体用法?Python MenuItem.set_label怎么用?Python MenuItem.set_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.set_label方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh_activity_list
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
def refresh_activity_list(self):
self.menu = Gtk.Menu()
def process_dir(activity_path):
for dir_name in sorted(os.listdir(activity_path)):
bundles_installed = []
if dir_name.endswith('.activity'):
bundle_dir = os.path.join(activity_path, dir_name)
bundle = ActivityBundle(bundle_dir)
bundles_installed.append(bundle)
item = MenuItem(file_name=bundle.get_icon(),
xo_color=xocolor.XoColor())
item.set_label(bundle.get_name())
item.set_reserve_indicator(True)
item.set_submenu(self.make_submenu(bundle))
self.menu.append(item)
process_dir('/usr/share/sugar/activities/')
process_dir(activities_path) # ~/Activities
separator = Gtk.SeparatorMenuItem()
self.menu.append(separator)
about = MenuItem()
about.set_label("About")
about.connect("activate", self.show_about_dialog)
self.menu.append(about)
quit = MenuItem()
quit.set_label("Quit")
quit.connect("activate", Gtk.main_quit)
self.menu.append(quit)
self.menu.show_all()
示例2: process_dir
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
def process_dir(activity_path):
for dir_name in sorted(os.listdir(activity_path)):
bundles_installed = []
if dir_name.endswith('.activity'):
bundle_dir = os.path.join(activity_path, dir_name)
bundle = ActivityBundle(bundle_dir)
bundles_installed.append(bundle)
item = MenuItem(file_name=bundle.get_icon(),
xo_color=xocolor.XoColor())
item.set_label(bundle.get_name())
item.set_reserve_indicator(True)
item.set_submenu(self.make_submenu(bundle))
self.menu.append(item)
示例3: make_submenu
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
def make_submenu(self, bundle):
submenu = Gtk.Menu()
newitem = MenuItem(icon_name='activity-start')
newitem.set_label("Start new")
newitem.connect("activate", self.launch, bundle)
submenu.append(newitem)
results, n = _datastore.find(
{'limit':10,
'activity':bundle.get_bundle_id()},
['uid', 'title', 'mime_type'])
if n>0:
separator = Gtk.SeparatorMenuItem()
submenu.append(separator)
for i in results:
title = ''.join([chr(byte) for byte in i['title']])
uid = i['uid']
item = MenuItem(file_name=bundle.get_icon(),
xo_color=xocolor.XoColor())
item.set_label(title)
item.connect("activate", self.launch_with_uid, bundle, uid)
submenu.append(item)
if n>0:
separator = Gtk.SeparatorMenuItem()
submenu.append(separator)
view_source = MenuItem(icon_name='view-source')
view_source.set_label("View Source")
view_source.connect("activate", self.view_source, bundle)
submenu.append(view_source)
return submenu