本文整理汇总了Python中card.Card.change_speak方法的典型用法代码示例。如果您正苦于以下问题:Python Card.change_speak方法的具体用法?Python Card.change_speak怎么用?Python Card.change_speak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.change_speak方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CardPair
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import change_speak [as 别名]
class CardPair(Gtk.EventBox):
__gsignals__ = {
'pair-selected': (GObject.SignalFlags.RUN_FIRST,
None, [GObject.TYPE_PYOBJECT]),
}
def __init__(self, text1, text2=None, aimg_path=None, bimg_path=None,
asnd=None, bsnd=None, aspeak=None, bspeak=None,
font_name1=None, font_name2=None):
Gtk.EventBox.__init__(self)
self.bg_color = '#d7d7d7'
self._stroke_color = '#ffffff'
self._fill_color = '#4c4d4f'
self.asnd = asnd
self.bsnd = bsnd
self.current_game_key = None
row = Gtk.VBox()
row.props.margin_left = style.DEFAULT_SPACING
row.props.margin_right = style.DEFAULT_SPACING
self.bcard1 = Card(
-1, {'front_text': {'card_text': text1,
'speak': aspeak,
'text_color': style.Color('#ffffff')},
'front': {'fill_color': style.Color(self._fill_color),
'stroke_color': style.Color(self._stroke_color)}},
aimg_path, PAIR_SIZE, self.bg_color, font_name1)
self.bcard1.flip()
self.bcard1.set_valign(Gtk.Align.CENTER)
row.pack_start(self.bcard1, True, True, 0)
self.bcard2 = Card(
-1, {'front_text': {'card_text': text2,
'speak': bspeak,
'text_color': style.Color('#ffffff')},
'front': {'fill_color': style.Color(self._fill_color),
'stroke_color': style.Color(self._stroke_color)}},
bimg_path, PAIR_SIZE, self.bg_color, font_name2)
self.bcard2.flip()
self.bcard2.set_valign(Gtk.Align.CENTER)
row.pack_start(self.bcard2, True, True, 0)
self.connect('button-press-event', self.emit_selected)
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(self.bg_color))
self.add(row)
self.show_all()
def emit_selected(self, widget, event):
self.emit('pair-selected', self)
def set_selected(self, status):
if not status:
stroke_color = self._stroke_color
fill_color = self._fill_color
else:
stroke_color = user_color.get_stroke_color()
fill_color = user_color.get_fill_color()
self.bcard1.set_border(stroke_color, fill_color)
self.bcard2.set_border(stroke_color, fill_color)
def change_image_path(self, aimage_path, bimage_path):
self.bcard1.set_image_path(aimage_path)
self.bcard2.set_image_path(bimage_path)
def change_text(self, text1, text2):
self.bcard1.change_text(text1)
self.bcard2.change_text(text2)
def change_sound(self, asnd, bsnd):
self.asnd = asnd
self.bsnd = bsnd
def change_font(self, card, font_name):
if card == 1:
self.bcard1.change_font(font_name)
else:
self.bcard2.change_font(font_name)
def get_text(self, card):
if card == 1:
return self.bcard1.get_text()
else:
return self.bcard2.get_text()
def change_speak(self, aspeak, bspeak):
self.bcard1.change_speak(aspeak)
self.bcard2.change_speak(bspeak)
def get_speak(self, card):
if card == 1:
return self.bcard1.get_speak()
else:
return self.bcard2.get_speak()
def get_image_path(self, card):
if card == 1:
#.........这里部分代码省略.........
示例2: CardEditor
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import change_speak [as 别名]
#.........这里部分代码省略.........
if self.usespeak is None:
return None
if self.usespeak.props.active:
return self.usespeak.palette.face.status.voice.language
def set_speak(self, value):
if self.usespeak is None:
return
if value is None:
self.usespeak.props.active = False
else:
try:
self.usespeak.handler_block_by_func(self._usespeak_cb)
self.usespeak.props.active = True
finally:
self.usespeak.handler_unblock_by_func(self._usespeak_cb)
self.usespeak.palette.voices.resume(value)
def get_image_path(self):
return self.card.get_image_path()
def set_image_path(self, image_path):
self.card.set_image_path(image_path)
self.emit('has-picture', True)
def _load_image(self, widget):
def load(jobject):
origin_path = jobject.file_path
self._game.model.mark_modified()
self._game.model.create_temp_directories()
destination_path = join(self._game.model.data['pathimg'],
basename(origin_path))
shutil.copy(origin_path, destination_path)
self.set_speak(None)
self.card.set_image_path(destination_path)
logging.debug('Picture Loaded: %s', destination_path)
self.emit('has-picture', True)
chooser.pick(parent=self.get_toplevel(),
what=chooser.IMAGE,
cb=load)
def _load_audio(self, widget):
def load(jobject):
origin_path = jobject.file_path
self.set_speak(None)
self._game.model.mark_modified()
self._game.model.create_temp_directories()
destination_path = join(self._game.model.data['pathsnd'],
basename(origin_path))
shutil.copy(origin_path, destination_path)
self.set_snd(destination_path)
logging.debug('Audio Loaded: %s', destination_path)
# add a icon too
sound_icon_path = join(activity.get_bundle_path(),
'icons/sound.svg')
destination_path = join(self._game.model.data['pathimg'],
'sound.svg')
shutil.copy(sound_icon_path, destination_path)
self.card.set_image_path(destination_path)
self.emit('has-sound', True)
chooser.pick(parent=self.get_toplevel(),
what=chooser.AUDIO,
cb=load)
def _usespeak_cb(self, button):
self.card.change_speak(button.props.active)
if not button.props.active:
self.usespeak.palette.face.shut_up()
return
self.snd = None
self.emit('has-sound', False)
self.emit('has-picture', False)
button.palette.face.say(self.get_text())
def set_snd(self, snd):
self.snd = snd
def get_snd(self):
return self.snd
def get_font_name(self):
return self.fontbutton.get_font_name()
def clean(self):
self.textentry.set_text('')
self.card.set_image_path(None)
self.snd = None
self.emit('has-text', False)
self.emit('has-picture', False)
self.emit('has-sound', False)
if self.usespeak is not None and self.usespeak.palette is not None:
self.usespeak.props.active = False
self.usespeak.palette.face.shut_up()