本文整理汇总了Python中gui.base.MarkupParser类的典型用法代码示例。如果您正苦于以下问题:Python MarkupParser类的具体用法?Python MarkupParser怎么用?Python MarkupParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MarkupParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: append
def append(self, text, cedict, cepath, scroll=True):
"""append formatted text to the widget"""
if self.config.b_show_emoticons:
text = MarkupParser.replace_emotes(text, cedict, cepath)
# Parse links
text = MarkupParser.urlify(text)
TextBox.append(self, text, scroll)
示例2: _prepare_markup
def _prepare_markup(self, markup, is_plus=True):
if is_plus:
text = Plus.msnplus_parse(markup)
else:
text = Plus.msnplus_strip(markup)
text = MarkupParser.replace_markup(text)
text_list = MarkupParser.replace_emoticons(text)
return text_list
示例3: send_message
def send_message(self, formatter, contact, message, cedict, cepath, is_first):
'''add a message to the widget'''
is_raw, consecutive, outgoing, first, last = \
formatter.format(contact, message.type)
if is_raw:
middle = MarkupParser.escape(message.body)
else:
middle = MarkupParser.escape(message.body)
middle = e3.common.add_style_to_message(middle, message.style, False)
all_ = first + middle + last
self.append(all_, cedict, cepath, self.config.b_allow_auto_scroll)
示例4: send_message
def send_message(self, formatter, contact, text, cedict, style, is_first):
"""add a message to the widget"""
nick = contact.display_name
is_raw, consecutive, outgoing, first, last = formatter.format(contact)
if is_raw:
middle = MarkupParser.escape(text)
else:
middle = MarkupParser.escape(text)
middle = e3.common.add_style_to_message(middle, style, False)
all_ = first + middle + last
self.append(all_, cedict, self.config.b_allow_auto_scroll)
示例5: send_message
def send_message(self, formatter, contact, text, cedict, cepath, style, is_first, type_=None):
"""add a message to the widget"""
is_raw, consecutive, outgoing, first, last = formatter.format(contact, type_)
if type_ == e3.Message.TYPE_NUDGE:
middle = ""
else:
if is_raw:
middle = MarkupParser.escape(text)
else:
middle = MarkupParser.escape(text)
middle = e3.common.add_style_to_message(middle, style, False)
all_ = first + middle + last
self.append(all_, cedict, self.config.b_allow_auto_scroll)
示例6: _build_display_role
def _build_display_role(self, index, is_group=False):
'''Build a string to be used as item's display role'''
model = index.model()
data_role = model.data(index, Role.DataRole).toPyObject()
if is_group:
display_role = self.contact_list.format_group(data_role)
else:
display_role = self.contact_list.format_nick(data_role)
text = self.plus_text_parse(display_role) if not is_group else display_role
text = MarkupParser.replace_markup(text)
if not is_group:
text_list = MarkupParser.replace_emoticons(text)
return text_list
return [text]
示例7: parse_emotes
def parse_emotes(text, include_table_tags=True):
'''Parses emotes in text string, returning a html string laid out
using a table, to vertically align emotes correctly'''
text = MarkupParser.replace_emotes(text)
parser = MyHTMLParser(include_table_tags)
parser.feed(text)
text2 = parser.get_data()
return text2
示例8: append_text
def append_text(self, text):
"""
adds text at the end of the actual text
"""
self.text = self.text + "\n" + text
self.messageLabel.set_text(self.markup2 % (self.FColor, MarkupParser.escape(self.text)))
self.messageLabel.set_use_markup(True)
self.messageLabel.show()
示例9: receive_message
def receive_message(self, formatter, contact, message, cedict, cepath, is_first):
'''add a message to the widget'''
is_raw, consecutive, outgoing, first, last = formatter.format(contact)
middle = MarkupParser.escape(message.body)
if not is_raw:
middle = e3.common.add_style_to_message(message.body, message.style)
self.append(first + middle + last, cedict, self.config.b_allow_auto_scroll)
示例10: _set_extension_info
def _set_extension_info(self, ext):
"""fill the information about the ext"""
name = self.get_attr_or_default(ext, 'NAME', '?')
description = self.get_attr_or_default(ext, 'DESCRIPTION', '?')
author = self.get_attr_or_default(ext, 'AUTHOR', '?')
website = self.get_attr_or_default(ext, 'WEBSITE', '?')
self.name_info.set_text(name)
self.description_info.set_text(description)
self.author_info.set_text(author)
self.website_info.set_markup(MarkupParser.urlify(website))
示例11: append
def append(self, text, cedict=None, scroll=True):
'''append formatted text to the widget'''
if not self.loaded:
self._texts.append(text)
return
if not self.config or self.config.b_show_emoticons:
text = MarkupParser.parse_emotes(text, cedict)
text = text.replace('\r\n', '<br/>').replace('\n', '<br/>')
text = self.parse_url(text)
text = text.replace('"', '\\"')
self._textbox.execute_script('add_message("%s");' % (text,))
if scroll:
self.scroll_to_end()
示例12: __init__
def __init__(self, title, text, picture_path, callback, tooltip):
gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)
# constants
self.FColor = "white"
max_width = 300
self.callback = callback
# window attributes
self.set_border_width(10)
# labels
self._title = title #nick
markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
titleLabel = gtk.Label(markup1 % (self.FColor, \
MarkupParser.escape(self._title)))
titleLabel.set_use_markup(True)
titleLabel.set_justify(gtk.JUSTIFY_CENTER)
titleLabel.set_ellipsize(pango.ELLIPSIZE_END)
self.text = text #status, message, etc...
self.markup2 = '<span foreground="%s">%s</span>'
self.messageLabel = gtk.Label(self.markup2 % (self.FColor,
MarkupParser.escape(self.text)))
self.messageLabel.set_use_markup(True)
self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)
Avatar = extension.get_default('avatar')
# image
avatarImage = Avatar(cell_dimension=48)
if picture_path:
picture_path = picture_path[7:]
avatarImage.set_from_file(picture_path)
# boxes
hbox = gtk.HBox() # main box
self.messageVbox = gtk.VBox() # title + message
lbox = gtk.HBox() # avatar + title/message
lbox.set_spacing(10)
lboxEventBox = gtk.EventBox() # detects mouse events
lboxEventBox.set_visible_window(False)
lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
lboxEventBox.connect("button_press_event", self.onClick)
lboxEventBox.add(lbox)
self.connect("button_press_event", self.onClick)
if tooltip is not None:
lboxEventBox.set_tooltip_text(tooltip)
# pack everything
self.messageVbox.pack_start(titleLabel, False, False)
self.messageVbox.pack_start(self.messageLabel, True, True)
lbox.pack_start(avatarImage, False, False)
lbox.pack_start(self.messageVbox, True, True)
hbox.pack_start(lboxEventBox, True, True)
self.add(hbox)
# change background color
self.set_app_paintable(True)
self.realize()
if hasattr(self, 'window'):
BColor = gtk.gdk.Color(0, 0, 0)
self.window.set_background(BColor)
else:
ABColor = gtk.gdk.RGBA(0,0,0,0)
state = self.get_state_flags()
self.override_background_color(state, ABColor)
# A bit of transparency to be less intrusive
self.set_opacity(0.85)
self.timerId = None
self.set_default_size(max_width,-1)
self.connect("size-allocate", self.relocate)
self.show_all()
示例13: append
def append(self, text, cedict,scroll=True):
'''append formatted text to the widget'''
if self.config.b_show_emoticons:
text = MarkupParser.parse_emotes(text, cedict)
TextBox.append(self, text, scroll)
示例14: __init__
def __init__(self, title, text, picturePath, callback):
gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)
# constants
self.FColor = "white"
BColor = gtk.gdk.Color()
avatar_size = 48;
max_width = 300;
self.callback = callback
# window attributes
self.set_border_width(10)
# labels
self._title = title #nick
markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
titleLabel = gtk.Label(markup1 % (self.FColor, \
MarkupParser.escape(self._title)))
titleLabel.set_use_markup(True)
titleLabel.set_justify(gtk.JUSTIFY_CENTER)
titleLabel.set_ellipsize(pango.ELLIPSIZE_END)
self.text = text #status, message, etc...
self.markup2 = '<span foreground="%s">%s</span>'
self.messageLabel = gtk.Label(self.markup2 % (self.FColor, \
MarkupParser.escape(self.text)))
self.messageLabel.set_use_markup(True)
self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)
# image
avatarImage = gtk.Image()
try:
userPixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
picturePath[7:], avatar_size, avatar_size)
except:
userPixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user,
(avatar_size, avatar_size))
avatarImage.set_from_pixbuf(userPixbuf)
# boxes
hbox = gtk.HBox() # main box
self.messageVbox = gtk.VBox() # title + message
lbox = gtk.HBox() # avatar + title/message
lbox.set_spacing(10)
lboxEventBox = gtk.EventBox() # detects mouse events
lboxEventBox.set_visible_window(False)
lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
lboxEventBox.connect("button_press_event", self.onClick)
lboxEventBox.add(lbox)
self.connect("button_press_event", self.onClick)
# pack everything
self.messageVbox.pack_start(titleLabel, False, False)
self.messageVbox.pack_start(self.messageLabel, True, True)
lbox.pack_start(avatarImage, False, False)
lbox.pack_start(self.messageVbox, True, True)
hbox.pack_start(lboxEventBox, True, True)
self.add(hbox)
# change background color
self.set_app_paintable(True)
self.realize()
self.window.set_background(BColor)
# A bit of transparency to be less intrusive
self.set_opacity(0.85)
self.timerId = None
self.set_default_size(max_width,-1)
self.connect("size-allocate", self.relocate)
self.show_all()
示例15: msnplus_to_list
def msnplus_to_list(text):
'''parse text and return a list of strings and gtk.gdk.Pixbufs'''
text = plus_text_parse(text)
text = MarkupParser.replace_markup(text)
text_list = MarkupParser.replace_emoticons(text)
return text_list