本文整理汇总了Python中gobject.markup_escape_text方法的典型用法代码示例。如果您正苦于以下问题:Python gobject.markup_escape_text方法的具体用法?Python gobject.markup_escape_text怎么用?Python gobject.markup_escape_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gobject
的用法示例。
在下文中一共展示了gobject.markup_escape_text方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_set_property
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def do_set_property(self, pspec, value):
if pspec.name == 'title':
self.__title.set_markup('<span weight="bold">%s</span>' %
gobject.markup_escape_text(value))
self.__title_text = value
else:
raise AttributeError, 'unknown property %s' % pspec.name
示例2: do_set_property
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def do_set_property(self, pspec, value):
"""!
Set property function
@param self: this object
@param pspec: internal
@param value: callback
@return AttributeError if unknown property
"""
if pspec.name == 'title':
self.__title.set_markup('<span weight="bold">%s</span>' %
gobject.markup_escape_text(value))
self.__title_text = value
else:
raise AttributeError, 'unknown property %s' % pspec.name
示例3: display_reset_prompt
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def display_reset_prompt(parent=None, more_settings_shown=False):
dialog = gtk.MessageDialog(
parent=parent,
type=gtk.MESSAGE_WARNING,
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
buttons=gtk.BUTTONS_YES_NO)
dialog.set_transient_for(parent)
dialog.set_title(pg.config.PLUGIN_TITLE)
dialog.set_markup(
gobject.markup_escape_text(_("Are you sure you want to reset settings?")))
if more_settings_shown:
checkbutton_reset_operations = gtk.CheckButton(
label=_("Remove procedures and constraints"), use_underline=False)
dialog.vbox.pack_start(checkbutton_reset_operations, expand=False, fill=False)
dialog.set_focus(dialog.get_widget_for_response(gtk.RESPONSE_NO))
dialog.show_all()
response_id = dialog.run()
dialog.destroy()
clear_operations = (
checkbutton_reset_operations.get_active() if more_settings_shown else False)
return response_id, clear_operations
示例4: _set_layer_name_label
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def _set_layer_name_label(self, layer_name):
self._label_layer_name.set_markup(
"<i>{}</i>".format(
gobject.markup_escape_text(layer_name.encode(pg.GTK_CHARACTER_ENCODING))))
示例5: _on_label_procedure_name_changed
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def _on_label_procedure_name_changed(self, editable_label, operation):
operation["display_name"].set_value(editable_label.label.get_text())
editable_label.label.set_markup(
"<b>{}</b>".format(gobject.markup_escape_text(editable_label.label.get_text())))
示例6: _choose
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def _choose(self, filepath):
if filepath is not None:
dirpath, filename = os.path.split(filepath)
if dirpath:
text_choose = (
_('A file named "{}" already exists in "{}". ').format(
filename, os.path.basename(dirpath)))
else:
text_choose = _('A file named "{}" already exists.\n').format(filename)
else:
text_choose = _("A file with the same name already exists.\n")
text_choose += _("What would you like to do?")
self._dialog_text.set_markup(
'<span font_size="large"><b>{}</b></span>'.format(
gobject.markup_escape_text(text_choose)))
self._dialog.show_all()
self._overwrite_mode = self._dialog.run()
if self._overwrite_mode not in self._values:
self._overwrite_mode = self.default_response
self._dialog.hide()
return self._overwrite_mode
示例7: set_text
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def set_text(self, text, message_type=gtk.MESSAGE_ERROR, clear_delay=None):
"""
Set the `text` of the label. The text is displayed in bold style.
If the text is too wide to fit the label or the text has multiple lines,
ellipsize the label and display a button that displays a popup containing
the full text when clicked. Only the first line is displayed in the label.
If `message_type` is `gtk.MESSAGE_ERROR`, use the red font color.
For other message types, use the font color assigned by the current theme.
If `clear_delay` is not `None` and `message_type` is not
`gtk.MESSAGE_ERROR`, make the message automatically disappear after the
specified delay in milliseconds. The timer is stopped if the popup is
displayed and restarted if the popup gets hidden.
"""
if not text:
self._label_text = ""
self._popup_text_lines = []
self._label_message.set_text(self._label_text)
return
lines = text.strip().split("\n")
first_line = lines[0]
first_line = first_line[0].upper() + first_line[1:]
if not first_line.endswith("."):
first_line += "."
self._label_text = first_line
self._popup_text_lines = lines[1:]
self._message_type = message_type
self._clear_delay = clear_delay
if message_type == gtk.MESSAGE_ERROR:
self._label_message.set_markup(
'<span foreground="red"><b>{}</b></span>'.format(gobject.markup_escape_text(
self._label_text.encode(pg.GTK_CHARACTER_ENCODING))))
self._timeout_remove_strict(self._clear_delay, self.set_text)
else:
self._label_message.set_markup(
"<b>{}</b>".format(gobject.markup_escape_text(
self._label_text.encode(pg.GTK_CHARACTER_ENCODING))))
self._timeout_add_strict(self._clear_delay, self.set_text, None)
示例8: __init__
# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import markup_escape_text [as 别名]
def __init__(self, operation, pdb_procedure, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_transient()
self.set_resizable(False)
self._button_ok = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
self._button_cancel = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
self.set_alternative_button_order([gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL])
self._button_reset = gtk.Button()
self._button_reset.set_label(_("_Reset"))
self.action_area.pack_start(self._button_reset, expand=False, fill=False)
self.action_area.set_child_secondary(self._button_reset, True)
self._label_procedure_name = pg.gui.EditableLabel()
self._label_procedure_name.label.set_use_markup(True)
self._label_procedure_name.label.set_ellipsize(pango.ELLIPSIZE_END)
self._label_procedure_name.label.set_markup(
"<b>{}</b>".format(gobject.markup_escape_text(operation["display_name"].value)))
self._label_procedure_name.connect(
"changed", self._on_label_procedure_name_changed, operation)
if pdb_procedure is not None:
self._label_procedure_short_description = gtk.Label()
self._label_procedure_short_description.set_line_wrap(True)
self._label_procedure_short_description.set_alignment(0.0, 0.5)
self._label_procedure_short_description.set_label(pdb_procedure.proc_blurb)
self._label_procedure_short_description.set_tooltip_text(pdb_procedure.proc_help)
self._table_operation_arguments = gtk.Table(homogeneous=False)
self._table_operation_arguments.set_row_spacings(self._TABLE_ROW_SPACING)
self._table_operation_arguments.set_col_spacings(self._TABLE_COLUMN_SPACING)
# Put widgets in a custom `VBox` because the action area would otherwise
# have excessively thick borders for some reason.
self._vbox = gtk.VBox()
self._vbox.set_border_width(self._DIALOG_BORDER_WIDTH)
self._vbox.set_spacing(self._DIALOG_VBOX_SPACING)
self._vbox.pack_start(self._label_procedure_name, expand=False, fill=False)
if pdb_procedure is not None:
self._vbox.pack_start(
self._label_procedure_short_description, expand=False, fill=False)
self._vbox.pack_start(self._table_operation_arguments, expand=True, fill=True)
self.vbox.pack_start(self._vbox, expand=False, fill=False)
self._set_arguments(operation, pdb_procedure)
self.set_focus(self._button_ok)
self._button_reset.connect("clicked", self._on_button_reset_clicked, operation)
self.connect("response", self._on_operation_edit_dialog_response)