本文整理匯總了Python中e3.common.RingBuffer.RingBuffer.peak方法的典型用法代碼示例。如果您正苦於以下問題:Python RingBuffer.peak方法的具體用法?Python RingBuffer.peak怎麽用?Python RingBuffer.peak使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類e3.common.RingBuffer.RingBuffer
的用法示例。
在下文中一共展示了RingBuffer.peak方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Conversation
# 需要導入模塊: from e3.common.RingBuffer import RingBuffer [as 別名]
# 或者: from e3.common.RingBuffer.RingBuffer import peak [as 別名]
#.........這裏部分代碼省略.........
def _set_image_visible(self, value):
'''hide or show the widget according to value'''
self.set_image_visible(value)
self._image_visible = value
def _get_image_visible(self):
'''return the value of image_visible'''
return self._image_visible
image_visible = property(fget=_get_image_visible,
fset=_set_image_visible)
def _set_header_visible(self, value):
'''hide or show the widget according to value'''
self.set_header_visible(value)
self._header_visible = value
def _get_header_visible(self):
'''return the value of _header_visible'''
return self._header_visible
header_visible = property(fget=_get_header_visible,
fset=_set_header_visible)
def _set_toolbar_visible(self, value):
'''hide or show the widget according to value'''
self.set_toolbar_visible(value)
self._toolbar_visible = value
def _get_toolbar_visible(self):
'''return the value of image_visible'''
return self._toolbar_visible
toolbar_visible = property(fget=_get_toolbar_visible,
fset=_set_toolbar_visible)
def play_nudge(self):
"""
play the nudge sound
"""
if self.session.config.b_play_nudge:
self.soundPlayer.play(gui.theme.sound_theme.sound_nudge)
def play_send(self):
"""
play the send sound
"""
if self.session.config.b_play_send:
self.soundPlayer.play(gui.theme.sound_theme.sound_send)
def play_type(self):
"""
play the receive sound
"""
if self.session.config.b_play_type and (self.message_waiting or not \
self.session.config.b_mute_sounds_when_focussed):
self.soundPlayer.play(gui.theme.sound_theme.sound_type)
def cycle_history(self, change=-1):
"""
return one of the last N messages sent, the one returned
is the one pointed by message_offset, every time you call
this function it will go to the previous one, you can
reset it using reset_message_offset.
change is the direction of cycling, 1 will go forward
-1 will go backwards
if no message in the buffer return an empty string
if there is message before cycling, it will be stored
till the message sent
"""
if change < 0 and self.message_offset == 0:
self.message_input = self.input.text
self.message_offset += change
if abs(self.message_offset) + 1 > len(self.messages):
self.message_offset=1 - len(self.messages)
if self.message_offset > 0:
self.reset_message_offset()
try:
if self.message_offset == 0:
self.input.text = self.message_input
else:
self.input.text = self.messages.peak(self.message_offset)
except IndexError:
pass
def reset_message_offset(self):
self.message_offset = 0
def _member_to_contact(self,member):
return self.session.contacts.safe_get(member)
def steal_emoticon(self, uri):
"""
receives the path or the uri for the emoticon to be added
"""
raise NotImplementedError("Method not implemented")
示例2: Conversation
# 需要導入模塊: from e3.common.RingBuffer import RingBuffer [as 別名]
# 或者: from e3.common.RingBuffer.RingBuffer import peak [as 別名]
#.........這裏部分代碼省略.........
def _update_single_information(self, account):
'''set the data of the conversation to the data of the account'''
contact = self.session.contacts.get(account)
if contact:
message = MarkupParser.escape(contact.message)
nick = MarkupParser.escape(contact.display_name)
else:
message = ''
nick = account
self.update_single_information(nick, message, account)
def _set_image_visible(self, value):
'''hide or show the widget according to value'''
self.set_image_visible(value)
if value:
self.info.show()
else:
self.info.hide()
self._image_visible = value
def _get_image_visible(self):
'''return the value of image_visible'''
return self._image_visible
image_visible = property(fget=_get_image_visible,
fset=_set_image_visible)
def _set_header_visible(self, value):
'''hide or show the widget according to value'''
self.set_header_visible(value)
self._header_visible = value
def _get_header_visible(self):
'''return the value of image_visible'''
return self._header_visible
header_visible = property(fget=_get_header_visible,
fset=_set_header_visible)
def _set_toolbar_visible(self, value):
'''hide or show the widget according to value'''
self.set_toolbar_visible(value)
self._toolbar_visible = value
def _get_toolbar_visible(self):
'''return the value of image_visible'''
return self._toolbar_visible
toolbar_visible = property(fget=_get_toolbar_visible,
fset=_set_toolbar_visible)
def play_nudge(self):
"""
play the nudge sound
"""
if self.session.config.b_play_nudge:
gui.play(self.session, gui.theme.sound_nudge)
def play_send(self):
"""
play the send sound
"""
if self.session.config.b_play_send:
gui.play(self.session, gui.theme.sound_send)
def play_type(self):
"""
play the receive sound
"""
if self.session.config.b_play_type and self.message_waiting:
gui.play(self.session, gui.theme.sound_type)
def cycle_history(self, change=-1):
"""
return one of the last N messages sent, the one returned
is the one pointed by message_offset, every time you call
this function it will go to the previous one, you can
reset it using reset_message_offset.
change is the direction of cycling, 1 will go forward
-1 will go backwards
if no message in the buffer return an empty string
"""
self.message_offset += change
try:
self.input.text = self.messages.peak(self.message_offset)
except IndexError:
pass
def reset_message_offset(self):
self.message_offset = 0
def _member_to_contact(self,member):
return self.session.contacts.contacts[member]