本文整理汇总了Python中sugar3.graphics.palette.Palette.set_content方法的典型用法代码示例。如果您正苦于以下问题:Python Palette.set_content方法的具体用法?Python Palette.set_content怎么用?Python Palette.set_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.palette.Palette
的用法示例。
在下文中一共展示了Palette.set_content方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_palette
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
def create_palette(self):
primary_text = GLib.markup_escape_text(self._model.bundle.get_name())
secondary_text = GLib.markup_escape_text(self._model.get_name())
palette_icon = Icon(file=self._model.bundle.get_icon(),
xo_color=self._model.get_color())
palette_icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
palette = Palette(None,
primary_text=primary_text,
secondary_text=secondary_text,
icon=palette_icon)
private = self._model.props.private
joined = get_owner_instance() in self._model.props.buddies
menu_box = PaletteMenuBox()
if joined:
item = PaletteMenuItem(_('Resume'))
icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
item.set_image(icon)
item.connect('activate', self.__palette_item_clicked_cb)
menu_box.append_item(item)
elif not private:
item = PaletteMenuItem(_('Join'))
icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
item.set_image(icon)
item.connect('activate', self.__palette_item_clicked_cb)
menu_box.append_item(item)
palette.set_content(menu_box)
menu_box.show_all()
self.connect_to_palette_pop_events(palette)
return palette
示例2: setup_rollover_options
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
def setup_rollover_options(self, info):
palette = Palette(info, text_maxlen=50)
self.set_palette(palette)
box = PaletteMenuBox()
palette.set_content(box)
box.show()
menu_item = PaletteMenuItem(_('Remove'), 'list-remove')
menu_item.connect('activate', self.item_remove_cb)
box.append_item(menu_item)
menu_item.show()
separator = PaletteMenuItemSeparator()
box.append_item(separator)
separator.show()
textview = Gtk.TextView()
textview.props.height_request = style.GRID_CELL_SIZE * 2
textview.props.width_request = style.GRID_CELL_SIZE * 3
textview.props.hexpand = True
textview.props.vexpand = True
box.append_item(textview)
textview.show()
buffer = textview.get_buffer()
if self.notes is None:
buffer.set_text(_('Take notes on this page'))
else:
buffer.set_text(self.notes)
buffer.connect('changed', self.__buffer_changed_cb)
示例3: __init__
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
def __init__(self, recd):
TrayButton.__init__(self)
self._recd = recd
self.set_icon_widget(self.get_image())
self._copy_menu_item_handler = None
palette = Palette(recd.title)
self.set_palette(palette)
self._box = PaletteMenuBox()
palette.set_content(self._box)
self._box.show()
self._rem_menu_item = PaletteMenuItem(
_('Erase'), icon_name='edit-delete')
self._rem_menu_item_handler = self._rem_menu_item.connect(
'activate', self._remove_clicked)
self._box.append_item(self._rem_menu_item)
self._rem_menu_item.show()
self._add_copy_menu_item()
示例4: create_palette
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
def create_palette(self):
primary_text = self._model.bundle.get_name()
secondary_text = self._model.get_name()
palette_icon = Icon(file=self._model.bundle.get_icon(),
pixel_size=style.STANDARD_ICON_SIZE,
xo_color=self._model.get_color())
palette = Palette(None,
primary_text=primary_text,
secondary_text=secondary_text,
icon=palette_icon)
private = self._model.props.private
joined = get_owner_instance() in self._model.props.buddies
is_joinable = self._is_joinable is None or self._is_joinable()
menu_box = PaletteMenuBox()
if joined:
item = PaletteMenuItem(_('Resume'))
icon = Icon(
pixel_size=style.SMALL_ICON_SIZE, icon_name='activity-start')
item.set_image(icon)
item.connect('activate', self.__palette_item_clicked_cb)
menu_box.append_item(item)
elif not private and is_joinable:
item = PaletteMenuItem(_('Join'))
icon = Icon(
pixel_size=style.SMALL_ICON_SIZE, icon_name='activity-start')
item.set_image(icon)
item.connect('activate', self.__palette_item_clicked_cb)
menu_box.append_item(item)
palette.set_content(menu_box)
menu_box.show_all()
self.connect_to_palette_pop_events(palette)
return palette
示例5: create_palette
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
def create_palette(self):
notification_box = NotificationBox(self._name)
palette = Palette(self._name)
palette.set_group_id('frame')
palette.set_content(notification_box)
self.set_palette(palette)
示例6: Palette
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
test = common.TestPalette()
palette = Palette('Test radio and toggle')
test.set_palette(palette)
box = Gtk.HBox()
toggle = Gtk.ToggleButton()
icon = Icon(icon_name='go-previous', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
toggle.set_image(icon)
box.pack_start(toggle, False)
toggle.show()
radio = Gtk.RadioButton()
icon = Icon(icon_name='go-next', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
radio.set_image(icon)
radio.set_mode(False)
box.pack_start(radio, False)
radio.show()
palette.set_content(box)
box.show()
if __name__ == '__main__':
common.main(test)
示例7: TagEditor
# 需要导入模块: from sugar3.graphics.palette import Palette [as 别名]
# 或者: from sugar3.graphics.palette.Palette import set_content [as 别名]
class TagEditor(Gtk.TextView):
def __init__(self, text, tag_list):
Gtk.TextView.__init__(self)
text_buffer = Gtk.TextBuffer()
self._test_hid = None
text_buffer.set_text(text)
self.set_buffer(text_buffer)
self._palette_invoker = TextViewInvoker(self)
self._palette_invoker.attach(self)
self.connect('destroy', self.__destroy_cb)
text_buffer.connect('changed', self.__buffer_changed_cb)
self.connect('move-cursor', self.__move_cursor_cb)
def __destroy_cb(self, icon):
if self._palette_invoker is not None:
self._palette_invoker.detach()
def __buffer_changed_cb(self, text_buffer):
self._delayed_word_test()
def __move_cursor_cb(self, text_view, step, count, extended_selection):
self._delayed_word_test()
def _delayed_word_test(self):
if self._test_hid is not None:
GObject.source_remove(self._test_hid)
self._test_hid = GObject.timeout_add(TIMEOUT, self._real_word_test)
def _real_word_test(self):
tbuffer = self.get_buffer()
cursor_position = tbuffer.props.cursor_position
text = tbuffer.get_text(
tbuffer.get_start_iter(), tbuffer.get_end_iter(), False)
if cursor_position == len(text):
if text[cursor_position - 1] == '#':
self._show_menu()
else:
previous_space = text.rfind(' ', 0, cursor_position)
if text[previous_space + 1] == '#':
self._show_menu()
def _show_menu(self):
logging.error('Show menu ')
if self._palette_invoker is not None:
self._palette = Palette(_('Select tag'))
menu_box = PaletteMenuBox()
self._palette.set_content(menu_box)
menu_box.show()
for tag in TAG_LIST:
menu_item = PaletteMenuItem()
menu_item.set_label(tag)
menu_item.connect('activate', self._add_tag, tag)
menu_box.append_item(menu_item)
menu_item.show()
self._palette_invoker.set_palette(self._palette)
self._palette.popup(immediate=True)
def _add_tag(self, menu, tag):
# probably this is not the best way to replace the word
tbuffer = self.get_buffer()
cursor_position = tbuffer.props.cursor_position
text = tbuffer.get_text(
tbuffer.get_start_iter(), tbuffer.get_end_iter(), False)
bold_tag = tbuffer.create_tag('b', weight=Pango.Weight.BOLD)
if cursor_position == len(text):
start_iter = tbuffer.get_iter_at_offset(len(text) - 2)
end_iter = tbuffer.get_end_iter()
else:
previous_space = text.rfind(' ', 0, cursor_position)
next_space = text.find(' ', cursor_position)
start_iter = tbuffer.get_iter_at_offset(previous_space)
end_iter = tbuffer.get_iter_at_offset(next_space)
tbuffer.delete(start_iter, end_iter)
tbuffer.insert_with_tags(start_iter, tag, bold_tag)