本文整理汇总了Python中sugar3.graphics.palettemenu.PaletteMenuItem.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python PaletteMenuItem.disconnect方法的具体用法?Python PaletteMenuItem.disconnect怎么用?Python PaletteMenuItem.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.palettemenu.PaletteMenuItem
的用法示例。
在下文中一共展示了PaletteMenuItem.disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RecdButton
# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import disconnect [as 别名]
class RecdButton(TrayButton):
__gsignals__ = {
'remove-requested': (GObject.SignalFlags.RUN_LAST, None, ()),
'copy-clipboard-requested': (GObject.SignalFlags.RUN_LAST, None, ()),
}
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()
def _add_copy_menu_item(self):
if self._recd.buddy and not self._recd.downloadedFromBuddy:
return
self._copy_menu_item = PaletteMenuItem(
_('Copy to clipboard'), icon_name='edit-copy')
self._copy_menu_item_handler = self._copy_menu_item.connect(
'activate', self._copy_clipboard_clicked)
self._box.append_item(self._copy_menu_item)
self._copy_menu_item.show()
def get_recd(self):
return self._recd
def get_image(self):
ipb = self._recd.getThumbPixbuf()
if ipb:
w = ipb.get_width()
h = ipb.get_height()
a = float(w) / float(h)
else:
a = 16. / 9
if a < 1.4:
paths = {constants.TYPE_PHOTO: 'object-photo.svg',
constants.TYPE_VIDEO: 'object-video.svg',
constants.TYPE_AUDIO: 'object-audio.svg'}
x = 8
y = 8
else:
paths = {constants.TYPE_PHOTO: 'object-photo-16to9.svg',
constants.TYPE_VIDEO: 'object-video-16to9.svg',
constants.TYPE_AUDIO: 'object-audio-16to9.svg'}
x = 9
y = 18
path = paths[self._recd.type]
pixbuf = utils.load_colored_svg(path, self._recd.colorStroke,
self._recd.colorFill)
if ipb:
ipb.composite(pixbuf, x, y, w, h, x, y, 1, 1,
GdkPixbuf.InterpType.BILINEAR, 255)
img = Gtk.Image()
img.set_from_pixbuf(pixbuf)
img.show()
return img
def cleanup(self):
self._rem_menu_item.disconnect(self._rem_menu_item_handler)
if self._copy_menu_item_handler is not None:
self._copy_menu_item.disconnect(self._copy_menu_item_handler)
def _remove_clicked(self, widget):
self.emit('remove-requested')
def _copy_clipboard_clicked(self, widget):
self.emit('copy-clipboard-requested')