本文整理汇总了Python中card.Card.change_font方法的典型用法代码示例。如果您正苦于以下问题:Python Card.change_font方法的具体用法?Python Card.change_font怎么用?Python Card.change_font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.change_font方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CardPair
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import change_font [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_font [as 别名]
class CardEditor(Gtk.EventBox):
__gsignals__ = {
'has-text': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'has-picture': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'has-sound': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'change-font': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
}
def __init__(self, game, editor_index):
Gtk.EventBox.__init__(self)
self._game = game
self.snd = None
self.editor_index = editor_index
self.temp_folder = None
box = Gtk.Grid()
box.set_column_spacing(style.DEFAULT_SPACING)
box.set_row_spacing(style.DEFAULT_SPACING)
box.props.margin = style.DEFAULT_SPACING
self.card = Card(
-1, {'front_text': {'card_text': '',
'text_color': style.Color('#ffffff')}},
None, PAIR_SIZE, '#c0c0c0')
self.card.flip()
card_align = Gtk.Alignment.new(.5, .5, 0, 0)
card_align.add(self.card)
box.attach(card_align, 0, 0, 1, 1)
self.textentry = Gtk.Entry()
self.textentry.connect('changed', self.update_text)
self.textentry.set_valign(Gtk.Align.START)
box.attach(self.textentry, 0, 1, 1, 1)
toolbar = Gtk.VBox()
toolbar.set_valign(Gtk.Align.CENTER)
browsepicture = ToolButton(icon_name='import_picture',
tooltip=_('Insert picture'))
toolbar.add(browsepicture)
browsesound = ToolButton(icon_name='import_sound',
tooltip=_('Insert sound'))
toolbar.add(browsesound)
browsepicture.connect('clicked', self._load_image)
browsesound.connect('clicked', self._load_audio)
self.usespeak = ToggleToolButton(icon_name='speak')
self.usespeak.set_palette(SpeakPalette(self))
toolbar.add(self.usespeak)
self.usespeak.connect('toggled', self._usespeak_cb)
self.fontbutton = FontButton()
toolbar.add(self.fontbutton)
self.id_font_changed = self.fontbutton.connect(
'changed', self.__font_changed_cb)
box.attach(toolbar, 1, 0, 1, 2)
self.add(box)
def __font_changed_cb(self, widget):
font = widget.get_font_name()
if font:
self.card.change_font(font)
self.emit('change-font', font)
def set_font_name(self, font_name):
self.fontbutton.handler_block(self.id_font_changed)
self.fontbutton.set_font_name(font_name)
self.fontbutton.handler_unblock(self.id_font_changed)
def update_text(self, entry):
self.card.change_text(entry.get_text())
if len(entry.get_text()) == 0:
self.emit('has-text', False)
else:
self.emit('has-text', True)
def get_text(self):
return self.textentry.get_text()
def set_text(self, newtext):
if newtext is None:
newtext = ''
self.textentry.set_text(newtext)
def get_speak(self):
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:
#.........这里部分代码省略.........