本文整理汇总了Python中sugar.graphics.menuitem.MenuItem.set_sensitive方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.set_sensitive方法的具体用法?Python MenuItem.set_sensitive怎么用?Python MenuItem.set_sensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.set_sensitive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar.graphics.menuitem.MenuItem import set_sensitive [as 别名]
def __init__(self):
gobject.GObject.__init__(self)
if filetransfer.file_transfer_available():
friends_model = friends.get_model()
for friend in friends_model:
if friend.is_present():
menu_item = MenuItem(text_label=friend.get_nick(),
icon_name='computer-xo',
xo_color=friend.get_color())
menu_item.connect('activate', self.__item_activate_cb,
friend)
self.append(menu_item)
menu_item.show()
if not self.get_children():
menu_item = MenuItem(_('No friends present'))
menu_item.set_sensitive(False)
self.append(menu_item)
menu_item.show()
else:
menu_item = MenuItem(_('No valid connection found'))
menu_item.set_sensitive(False)
self.append(menu_item)
menu_item.show()
示例2: SpeechPalette
# 需要导入模块: from sugar.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar.graphics.menuitem.MenuItem import set_sensitive [as 别名]
class SpeechPalette(Palette):
def __init__(self, primary_text, manager):
Palette.__init__(self, label=primary_text)
self._manager = manager
self._manager.connect('play', self._set_menu_state, 'play')
self._manager.connect('stop', self._set_menu_state, 'stop')
self._manager.connect('pause', self._set_menu_state, 'pause')
vbox = gtk.VBox()
self.set_content(vbox)
self._play_icon = Icon(icon_name='player_play')
self._pause_icon = Icon(icon_name='player_pause')
self._play_pause_menu = MenuItem(text_label=_('Say selected text'))
self._play_pause_menu.set_image(self._play_icon)
self._play_pause_menu.connect('activate', self.__play_activated_cb)
self._play_pause_menu.show()
self._stop_menu = MenuItem(icon_name='player_stop',
text_label=_('Stop playback'))
self._stop_menu.connect('activate', self.__stop_activated_cb)
self._stop_menu.set_sensitive(False)
self._stop_menu.show()
self.menu.append(self._play_pause_menu)
self.menu.append(self._stop_menu)
self._adj_pitch = gtk.Adjustment(value=self._manager.get_pitch(),
lower=self._manager.MIN_PITCH,
upper=self._manager.MAX_PITCH)
self._hscale_pitch = gtk.HScale(self._adj_pitch)
self._hscale_pitch.set_draw_value(False)
vbox.pack_start(gtk.Label(_('Pitch')), padding=style.DEFAULT_PADDING)
vbox.pack_start(self._hscale_pitch)
self._adj_rate = gtk.Adjustment(value=self._manager.get_rate(),
lower=self._manager.MIN_RATE,
upper=self._manager.MAX_RATE)
self._hscale_rate = gtk.HScale(self._adj_rate)
self._hscale_rate.set_draw_value(False)
vbox.pack_start(gtk.Label(_('Rate')), padding=style.DEFAULT_PADDING)
vbox.pack_start(self._hscale_rate)
vbox.show_all()
self._adj_pitch.connect('value_changed', self.__adj_pitch_changed_cb)
self._adj_rate.connect('value_changed', self.__adj_rate_changed_cb)
def __adj_pitch_changed_cb(self, adjustement):
self._manager.set_pitch(int(adjustement.value))
def __adj_rate_changed_cb(self, adjustement):
self._manager.set_rate(int(adjustement.value))
def __play_activated_cb(self, widget):
if self._manager.is_paused:
self._manager.restart()
elif not self._manager.is_playing:
self._manager.say_selected_text()
else:
self._manager.pause()
def __stop_activated_cb(self, widget):
self._manager.stop()
def _set_menu_state(self, manager, signal):
if signal == 'play':
self._play_pause_menu.set_image(self._pause_icon)
self._play_pause_menu.set_label(_('Pause playback'))
self._stop_menu.set_sensitive(True)
elif signal == 'pause':
self._play_pause_menu.set_image(self._play_icon)
self._play_pause_menu.set_label(_('Say selected text'))
self._stop_menu.set_sensitive(True)
elif signal == 'stop':
self._play_pause_menu.set_image(self._play_icon)
self._play_pause_menu.set_label(_('Say selected text'))
self._stop_menu.set_sensitive(False)