本文整理汇总了Python中gui.base.MarkupParser.escape方法的典型用法代码示例。如果您正苦于以下问题:Python MarkupParser.escape方法的具体用法?Python MarkupParser.escape怎么用?Python MarkupParser.escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.base.MarkupParser
的用法示例。
在下文中一共展示了MarkupParser.escape方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_message
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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)
示例2: send_message
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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)
示例3: send_message
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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)
示例4: append_text
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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()
示例5: receive_message
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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)
示例6: __init__
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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()
示例7: __init__
# 需要导入模块: from gui.base import MarkupParser [as 别名]
# 或者: from gui.base.MarkupParser import escape [as 别名]
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()