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


Python RingBuffer.RingBuffer类代码示例

本文整理汇总了Python中e3.common.RingBuffer.RingBuffer的典型用法代码示例。如果您正苦于以下问题:Python RingBuffer类的具体用法?Python RingBuffer怎么用?Python RingBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, session, cid, update_window, members=None):
        '''constructor'''
        self.update_window = update_window
        self.session = session
        self.caches = e3.cache.CacheManager(self.session.config_dir.base_dir)
        self.emcache = self.caches.get_emoticon_cache(self.session.account.account)

        self.cid = float(cid)
        self.formatter = e3.common.MessageFormatter(session.contacts.me)
        self.first = True

        self._header_visible = True
        self._image_visible = True
        self._toolbar_visible = True

        self._message_waiting = True

        buffer_size = session.config.get_or_set("i_msg_history_size", 5)
        self.messages = RingBuffer(max=buffer_size)
        self.message_offset = 0

        if members is None:
            self.members = []
        else:
            self.members = members

        self._style = None

        # the base class should override this attributes
        self.info = None
        self.input = None
        self.output = None
开发者ID:abranches,项目名称:emesene,代码行数:32,代码来源:Conversation.py

示例2: __init__

    def __init__(self, session, cid, update_window, members=None):
        '''constructor'''
        self.update_window = update_window
        self.session = session
        self.caches = e3.cache.CacheManager(self.session.config_dir.base_dir)
        self.emcache = self.caches.get_emoticon_cache(self.session.account.account)

        self.cid = float(cid)
        self.icid = self.cid
        self.formatter = e3.common.MessageFormatter()

        self._header_visible = True
        self._image_visible = True
        self._toolbar_visible = True

        self._message_waiting = False

        buffer_size = 10
        self.messages = RingBuffer(max=buffer_size)
        self.message_offset = 0

        if members is None:
            self.members = []
        else:
            self.members = members

        self._style = None

        self.conv_status = ConversationStatus.ConversationStatus(self.session.config)

        # the base class should override this attributes
        self.info = None
        self.input = None
        self.output = None
        self.soundPlayer = extension.get_and_instantiate('sound', session)
开发者ID:zipatei,项目名称:emesene,代码行数:35,代码来源:Conversation.py

示例3: Conversation

class Conversation(object):
    '''a widget that contains all the components inside'''

    def __init__(self, session, cid, update_window, members=None):
        '''constructor'''
        self.update_window = update_window
        self.session = session
        self.caches = e3.cache.CacheManager(self.session.config_dir.base_dir)
        self.emcache = self.caches.get_emoticon_cache(self.session.account.account)

        self.cid = float(cid)
        self.icid = self.cid
        self.formatter = e3.common.MessageFormatter()

        self._header_visible = True
        self._image_visible = True
        self._toolbar_visible = True

        self._message_waiting = False

        buffer_size = 10
        self.messages = RingBuffer(max=buffer_size)
        self.message_offset = 0
        self.message_input = ""

        if members is None:
            self.members = []
        else:
            self.members = members

        self._style = None

        self.conv_status = ConversationStatus.ConversationStatus(self.session.config)

        # the base class should override this attributes
        self.info = None
        self.input = None
        self.output = None
        self.soundPlayer = extension.get_and_instantiate('sound', session)

    def subscribe_signals(self):
        ''' subscribes current session's signals '''
        self.session.config.subscribe(self._on_avatarsize_changed,
                                     'i_conv_avatar_size')
        self.session.config.subscribe(self._on_show_toolbar_changed,
                                      'b_show_toolbar')
        self.session.config.subscribe(self._on_show_header_changed,
                                      'b_show_header')
        self.session.config.subscribe(self._on_show_info_changed,
                                      'b_show_info')
        self.session.config.subscribe(self._on_show_avatar_onleft,
                                      'b_avatar_on_left')
        self.session.config.subscribe(self._on_icon_size_change,
                                      'b_toolbar_small')
        self.session.signals.picture_change_succeed.subscribe(
            self.on_picture_change_succeed)
        self.session.signals.contact_attr_changed.subscribe(
            self.on_contact_attr_changed_succeed)

        self.session.signals.filetransfer_invitation.subscribe(
                self.on_filetransfer_invitation)
        self.session.signals.filetransfer_accepted.subscribe(
                self.on_filetransfer_accepted)
        self.session.signals.filetransfer_progress.subscribe(
                self.on_filetransfer_progress)
        self.session.signals.filetransfer_completed.subscribe(
                self.on_filetransfer_completed)
        self.session.signals.filetransfer_rejected.subscribe(
                self.on_filetransfer_rejected)
        self.session.signals.filetransfer_canceled.subscribe(
                self.on_filetransfer_canceled)

        self.session.signals.call_invitation.subscribe(
                self.on_call_invitation)

        self.session.signals.contact_block_succeed.subscribe(
                self.on_contact_block_succeed)
        self.session.signals.contact_unblock_succeed.subscribe(
                self.on_contact_unblock_succeed)

    def unsubscribe_signals(self):
        ''' unsubscribes current session's signals '''
        self.session.config.unsubscribe(self._on_avatarsize_changed,
            'i_conv_avatar_size')
        self.session.config.unsubscribe(self._on_show_toolbar_changed,
            'b_show_toolbar')
        self.session.config.unsubscribe(self._on_show_header_changed,
            'b_show_header')
        self.session.config.unsubscribe(self._on_show_info_changed,
            'b_show_info')
        self.session.config.unsubscribe(self._on_show_avatar_onleft,
            'b_avatar_on_left')
        self.session.config.unsubscribe(self._on_icon_size_change,
            'b_toolbar_small')
        self.session.signals.picture_change_succeed.unsubscribe(
            self.on_picture_change_succeed)
        self.session.signals.contact_attr_changed.unsubscribe(
            self.on_contact_attr_changed_succeed)

        self.session.signals.filetransfer_invitation.unsubscribe(
#.........这里部分代码省略.........
开发者ID:Stiveknx,项目名称:emesene,代码行数:101,代码来源:Conversation.py

示例4: Conversation

class Conversation(object):
    '''a widget that contains all the components inside'''

    def __init__(self, session, cid, update_window, members=None):
        '''constructor'''
        self.update_window = update_window
        self.session = session
        self.caches = e3.cache.CacheManager(self.session.config_dir.base_dir)
        self.emcache = self.caches.get_emoticon_cache(self.session.account.account)

        self.cid = float(cid)
        self.formatter = e3.common.MessageFormatter(session.contacts.me)
        self.first = True

        self._header_visible = True
        self._image_visible = True
        self._toolbar_visible = True

        self._message_waiting = True

        buffer_size = session.config.get_or_set("i_msg_history_size", 5)
        self.messages = RingBuffer(max=buffer_size)
        self.message_offset = 0

        if members is None:
            self.members = []
        else:
            self.members = members

        self._style = None

        # the base class should override this attributes
        self.info = None
        self.input = None
        self.output = None

    def _get_style(self):
        '''return the value of style'''
        return self._style

    def _set_style(self, style):
        '''set the value of style and update the style on input'''
        self._style = style
        self.session.config.font = style.font
        self.session.config.i_font_size = style.size
        self.session.config.b_font_bold = style.bold
        self.session.config.b_font_italic = style.italic
        self.session.config.b_font_underline = style.underline
        self.session.config.b_font_strike = style.strike
        self.session.config.font_color = '#' + style.color.to_hex()
        self.input.update_style(style)

    cstyle = property(fget=_get_style, fset=_set_style)

    def _load_style(self):
        '''load the default style from the configuration'''
        font = self.session.config.get_or_set("font", "Sans")
        font_color = self.session.config.get_or_set("font_color", "#000000")
        font_size = self.session.config.get_or_set("i_font_size", 10)
        font_bold = self.session.config.get_or_set("b_font_bold", False)
        font_italic = self.session.config.get_or_set("b_font_italic", False)
        font_underline = self.session.config.get_or_set("b_font_underline",
                False)
        font_strike = self.session.config.get_or_set("b_font_strike", False)

        if self.session.config.i_font_size < 6 or \
                self.session.config.i_font_size > 32:
            font_size = self.session.config.i_font_size = 10

        try:
            color = e3.Color.from_hex(font_color)
        except ValueError:
            font_color = self.session.config.font_color = '#000000'
            color = e3.Color.from_hex(font_color)

        self.cstyle = e3.Style(font, color, font_bold, font_italic,
            font_underline, font_strike, font_size)

    def get_preview(self, completepath):
        return None

    def on_font_selected(self, style):
        '''called when a new font is selected'''
        self.cstyle = style

    def on_color_selected(self, color):
        '''called when a new font is selected'''
        self.cstyle.color = color
        self.session.config.font_color = '#' + color.to_hex()
        self.input.update_style(self.cstyle)

    def on_style_selected(self, style):
        '''called when a new font is selected'''
        self.cstyle = style

    def on_invite(self, account):
        '''called when a contact is selected to be invited'''
        self.session.conversation_invite(self.cid, account)

    def on_filetransfer_invite(self, filename, completepath):
#.........这里部分代码省略.........
开发者ID:abranches,项目名称:emesene,代码行数:101,代码来源:Conversation.py


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