本文整理汇总了Python中sugar.graphics.menuitem.MenuItem.show_all方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.show_all方法的具体用法?Python MenuItem.show_all怎么用?Python MenuItem.show_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.show_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReadSDComics
# 需要导入模块: from sugar.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar.graphics.menuitem.MenuItem import show_all [as 别名]
#.........这里部分代码省略.........
def extract_image(self, filename):
zf = zipfile.ZipFile(filename, 'r')
image_files = zf.namelist()
image_files.sort()
file_to_extract = image_files[0]
extract_new_filename = self.make_new_filename(file_to_extract)
if extract_new_filename is None or extract_new_filename == '':
# skip over directory name if the images are in a subdirectory.
file_to_extract = image_files[1]
extract_new_filename = self.make_new_filename(file_to_extract)
if len(image_files) > 0:
if self.save_extracted_file(zf, file_to_extract):
fname = os.path.join(self.get_activity_root(), 'instance',
extract_new_filename)
return fname
def create_new_toolbar(self):
toolbar_box = ToolbarBox()
activity_button = MyActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
self.connect('go-fullscreen', \
self.__view_toolbar_go_fullscreen_cb)
self.back = ToolButton('go-previous')
self.back.set_tooltip(_('Back'))
self.back.props.sensitive = False
palette = self.back.get_palette()
self.menu_prev_page = MenuItem(text_label= _("Previous page"))
palette.menu.append(self.menu_prev_page)
self.menu_prev_page.show_all()
self.back.connect('clicked', self.go_back_cb)
self.menu_prev_page.connect('activate', self.go_back_cb)
toolbar_box.toolbar.insert(self.back, -1)
self.back.show()
self.forward = ToolButton('go-next')
self.forward.set_tooltip(_('Forward'))
self.forward.props.sensitive = False
palette = self.forward.get_palette()
self.menu_next_page = MenuItem(text_label= _("Next page"))
palette.menu.append(self.menu_next_page)
self.menu_next_page.show_all()
self.forward.connect('clicked', self.go_forward_cb)
self.menu_next_page.connect('activate', self.go_forward_cb)
toolbar_box.toolbar.insert(self.forward, -1)
self.forward.show()
num_page_item = gtk.ToolItem()
self.num_page_entry = gtk.Entry()
self.num_page_entry.set_text('0')
self.num_page_entry.set_alignment(1)
self.num_page_entry.connect('insert-text',
self.__new_num_page_entry_insert_text_cb)
self.num_page_entry.connect('activate',
self.__new_num_page_entry_activate_cb)
self.num_page_entry.set_width_chars(4)
num_page_item.add(self.num_page_entry)
self.num_page_entry.show()
toolbar_box.toolbar.insert(num_page_item, -1)
num_page_item.show()
total_page_item = gtk.ToolItem()
示例2: ReadToolbar
# 需要导入模块: from sugar.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar.graphics.menuitem.MenuItem import show_all [as 别名]
class ReadToolbar(gtk.Toolbar):
__gtype_name__ = 'ReadToolbar'
def __init__(self):
gtk.Toolbar.__init__(self)
self.back = ToolButton('go-previous')
self.back.set_tooltip(_('Back'))
self.back.props.sensitive = False
palette = self.back.get_palette()
self.prev_page = MenuItem(text_label= _("Previous page"))
palette.menu.append(self.prev_page)
self.prev_page.show_all()
self.back.connect('clicked', self.go_back_cb)
self.prev_page.connect('activate', self.go_back_cb)
self.insert(self.back, -1)
self.back.show()
self.forward = ToolButton('go-next')
self.forward.set_tooltip(_('Forward'))
self.forward.props.sensitive = False
palette = self.forward.get_palette()
self.next_page = MenuItem(text_label= _("Next page"))
palette.menu.append(self.next_page)
self.next_page.show_all()
self.forward.connect('clicked', self.go_forward_cb)
self.next_page.connect('activate', self.go_forward_cb)
self.insert(self.forward, -1)
self.forward.show()
num_page_item = gtk.ToolItem()
self._num_page_entry = gtk.Entry()
self._num_page_entry.set_text('0')
self._num_page_entry.set_alignment(1)
self._num_page_entry.connect('insert-text',
self._num_page_entry_insert_text_cb)
self._num_page_entry.connect('activate',
self._num_page_entry_activate_cb)
self._num_page_entry.set_width_chars(4)
num_page_item.add(self._num_page_entry)
self._num_page_entry.show()
self.insert(num_page_item, -1)
num_page_item.show()
total_page_item = gtk.ToolItem()
self._total_page_label = gtk.Label()
label_attributes = pango.AttrList()
label_attributes.insert(pango.AttrSize(14000, 0, -1))
label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
self._total_page_label.set_attributes(label_attributes)
self._total_page_label.set_text(' / 0')
total_page_item.add(self._total_page_label)
self._total_page_label.show()
self.insert(total_page_item, -1)
total_page_item.show()
def _num_page_entry_insert_text_cb(self, entry, text, length, position):
if not re.match('[0-9]', text):
entry.emit_stop_by_name('insert-text')
return True
return False
def _num_page_entry_activate_cb(self, entry):
if entry.props.text:
page = int(entry.props.text) - 1
else:
page = 0
if page >= self.total_pages:
page = self.total_pages - 1
elif page < 0:
page = 0
self.current_page = page
self.activity.set_current_page(page)
self.activity.show_page(page)
entry.props.text = str(page + 1)
self._update_nav_buttons()
def go_back_cb(self, button):
self.activity.previous_page()
def go_forward_cb(self, button):
self.activity.next_page()
def _update_nav_buttons(self):
current_page = self.current_page
self.back.props.sensitive = current_page > 0
self.forward.props.sensitive = \
current_page < self.total_pages - 1
self._num_page_entry.props.text = str(current_page + 1)
self._total_page_label.props.label = \
#.........这里部分代码省略.........