当前位置: 首页>>代码示例>>Python>>正文


Python Card.get_image_path方法代码示例

本文整理汇总了Python中card.Card.get_image_path方法的典型用法代码示例。如果您正苦于以下问题:Python Card.get_image_path方法的具体用法?Python Card.get_image_path怎么用?Python Card.get_image_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在card.Card的用法示例。


在下文中一共展示了Card.get_image_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CardPair

# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import get_image_path [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:
#.........这里部分代码省略.........
开发者ID:godiard,项目名称:memorize-activity,代码行数:103,代码来源:cardlist.py

示例2: CardEditor

# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import get_image_path [as 别名]

#.........这里部分代码省略.........
        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:
            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)
开发者ID:godiard,项目名称:memorize-activity,代码行数:70,代码来源:createcardpanel.py


注:本文中的card.Card.get_image_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。