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


Python Pango.FontDescription方法代码示例

本文整理汇总了Python中gi.repository.Pango.FontDescription方法的典型用法代码示例。如果您正苦于以下问题:Python Pango.FontDescription方法的具体用法?Python Pango.FontDescription怎么用?Python Pango.FontDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Pango的用法示例。


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

示例1: draw

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def draw(self, canvas, cr):
        Gdk.cairo_set_source_rgba(cr, self.bg_color)
        cr.rectangle(self.x, self.y, self.width, self.height)
        cr.fill()

        Gdk.cairo_set_source_rgba(cr, self.fg_color)
        cr.rectangle(self.x, self.y, self.width, self.height)
        cr.stroke()

        layout = canvas.create_pango_layout('F')
        font = Pango.FontDescription('Sans')
        layout.set_font_description(font)
        width, height = layout.get_size()

        Gdk.cairo_set_source_rgba(cr, self.fg_color)
        cr.move_to(self.x, self.y)
        PangoCairo.show_layout(cr, layout)

#-------------------------------------------------------------------------
#
# QuiltView
#
#------------------------------------------------------------------------- 
开发者ID:gramps-project,项目名称:addons-source,代码行数:25,代码来源:QuiltView.py

示例2: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self, application, hostname, key):
		"""
		:param application: The application to associate this popup dialog with.
		:type application: :py:class:`.KingPhisherClientApplication`
		:param str hostname: The hostname associated with the key.
		:param key: The host's SSH key.
		:type key: :py:class:`paramiko.pkey.PKey`
		"""
		super(BaseHostKeyDialog, self).__init__(application)
		self.hostname = hostname
		self.key = key
		textview = self.gobjects['textview_key_details']
		textview.modify_font(Pango.FontDescription('monospace 9'))
		textview.get_buffer().set_text(self.key_details)
		if self.default_response is not None:
			button = self.dialog.get_widget_for_response(response_id=self.default_response)
			button.grab_default() 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:19,代码来源:ssh_host_key.py

示例3: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self, application, exc_info=None, error_uid=None):
		"""
		:param application: The parent application for this object.
		:type application: :py:class:`Gtk.Application`
		:param tuple exc_info: The exception information as provided by :py:func:`sys.exc_info`.
		:param str error_uid: An optional unique identifier for the exception that can be provided for tracking purposes.
		"""
		super(ExceptionDialog, self).__init__(application)
		self.error_description = self.gtk_builder_get('label_error_description')
		self.error_details = self.gtk_builder_get('textview_error_details')
		self.error_details.modify_font(Pango.FontDescription('monospace 9'))
		self.exc_info = exc_info or sys.exc_info()
		self.error_uid = error_uid
		linkbutton = self.gobjects['linkbutton_github_issues']
		linkbutton.set_label('Project Issue Tracker')
		linkbutton.connect('activate-link', lambda _: utilities.open_uri(linkbutton.get_property('uri'))) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:18,代码来源:exception.py

示例4: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(label='Send')
		"""The :py:class:`Gtk.Label` representing this tabs name."""
		super(MailSenderSendTab, self).__init__(*args, **kwargs)
		self.textview = self.gobjects['textview_mail_sender_progress']
		"""The :py:class:`Gtk.TextView` object that renders text status messages."""
		self.textview.modify_font(Pango.FontDescription(self.config['text_font']))
		self.textbuffer = self.textview.get_buffer()
		"""The :py:class:`Gtk.TextBuffer` instance associated with :py:attr:`~.MailSenderSendTab.textview`."""
		self.textbuffer_iter = self.textbuffer.get_start_iter()
		self.progressbar = self.gobjects['progressbar_mail_sender']
		"""The :py:class:`Gtk.ProgressBar` instance which is used to display progress of sending messages."""
		self.pause_button = self.gobjects['togglebutton_mail_sender_pause']
		self.sender_thread = None
		"""The :py:class:`.MailSenderThread` instance that is being used to send messages."""
		self.application.connect('exit', self.signal_kpc_exit)
		self.application.connect('exit-confirm', self.signal_kpc_exit_confirm)
		self.textview.connect('populate-popup', self.signal_textview_populate_popup) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:20,代码来源:mail.py

示例5: fontstyle_to_fontdescription

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def fontstyle_to_fontdescription(font_style):
    """Convert a FontStyle instance to a Pango.FontDescription one.

    Font color and underline are not implemented in Pango.FontDescription,
    and have to be set with Pango.Layout.set_attributes(attrlist) method.

    """
    if font_style.get_bold():
        f_weight = Pango.Weight.BOLD
    else:
        f_weight = Pango.Weight.NORMAL

    if font_style.get_italic():
        f_style = Pango.Style.ITALIC
    else:
        f_style = Pango.Style.NORMAL

    font_description = Pango.FontDescription(font_families[font_style.face])
    font_description.set_size(int(round(font_style.get_size() * Pango.SCALE)))
    font_description.set_weight(f_weight)
    font_description.set_style(f_style)

    return font_description 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:25,代码来源:libcairodoc.py

示例6: ScrolledTextView

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def ScrolledTextView(text=None, monospace=False, **kwarg):
	'''Initializes a C{Gtk.TextView} with sane defaults for displaying a
	piece of multiline text and wraps it in a scrolled window

	@param text: initial text to show in the textview
	@param monospace: when C{True} the font will be set to monospaced
	and line wrapping disabled, use this to display log files etc.
	@param kwarg: arguments passed on to L{ScrolledWindow}
	@returns: a 2-tuple of the scrolled window and the textview
	'''
	textview = Gtk.TextView()
	textview.set_editable(False)
	textview.set_left_margin(5)
	textview.set_right_margin(5)
	if monospace:
		font = Pango.FontDescription('Monospace')
		textview.modify_font(font)
	else:
		textview.set_wrap_mode(Gtk.WrapMode.WORD)

	if text:
		textview.get_buffer().set_text(text)
	window = ScrolledWindow(textview, **kwarg)
	return window, textview 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:26,代码来源:widgets.py

示例7: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self, day_text_view):
        super().__init__()
        self.day_text_view = day_text_view

        self._connect_undo_signals()

        self.search_text = ""

        # spell checker
        self._spell_checker = None
        self.enable_spell_check(False)

        # Enable drag&drop
        self.day_text_view.connect("drag-data-received", self.on_drag_data_received)

        # Sometimes making the editor window very small causes the program to freeze
        # So we forbid that behaviour, by setting a minimum width
        self.day_text_view.set_size_request(1, -1)

        self.font = Pango.FontDescription(DEFAULT_FONT)
        self.default_size = self.font.get_size() / Pango.SCALE
        logging.debug("Default font: %s" % self.font.to_string())
        logging.debug("Default size: %s" % self.default_size) 
开发者ID:jendrikseipp,项目名称:rednotebook,代码行数:25,代码来源:editor.py

示例8: cairo_font

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def cairo_font(tk_font):
  family, size, weight = tk_font
  return pango.FontDescription('{} {} {}'.format(family, weight, size)) 
开发者ID:kevinpt,项目名称:symbolator,代码行数:5,代码来源:cairo_backend.py

示例9: create_about_tab

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def create_about_tab(self):
        from gi.repository import Pango
        page = Gtk.VBox()
        page.show()
        tv = Gtk.TextView()
        tv.set_editable(False)
        tv.set_cursor_visible(False)
        tv.modify_font(Pango.FontDescription(MONOSPACE_FONT))
        scroll = Gtk.ScrolledWindow()
        scroll.add(tv)
        page.pack_start(scroll, True, True, 0)
        self.info = tv.get_buffer()
        self.add_tab(page, 'Wall') 
开发者ID:mazaclub,项目名称:encompass,代码行数:15,代码来源:gtk.py

示例10: flow_changed

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def flow_changed(self, active):
        """
        Changes the wrap/font of text flow.
        """
        if active:
            # Set the text style to monospace
            self.texteditor.set_wrap_mode(Gtk.WrapMode.NONE)
            self.texteditor.modify_font(Pango.FontDescription("monospace"))
        else:
            # Set the text style to normal
            self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
            self.texteditor.modify_font(Pango.FontDescription("normal")) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:14,代码来源:NoteGramplet.py

示例11: font_dialog_ok

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def font_dialog_ok(self, widget):
        self.font = self.font_chooser.get_font_name()
        self.remarkable_settings['font'] = self.font # Save prefs
        self.write_settings()    
        self.text_view.override_font(Pango.FontDescription(self.font))

        # Now adjust the size using TextTag
        self.font_dialog_destroyed(self) 
开发者ID:jamiemcg,项目名称:Remarkable,代码行数:10,代码来源:RemarkableWindow.py

示例12: get_text_layout

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def get_text_layout(cairo_context, text, size):
    c = cairo_context
    layout = PangoCairo.create_layout(c)
    layout.set_text(text, -1)

    font_name = constants.INTERFACE_FONT

    font = FontDescription(font_name + " " + str(size))
    layout.set_font_description(font)

    return layout 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:13,代码来源:gap_draw_helper.py

示例13: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self):
        GtkSource.Map.__init__(self)

        self.set_vexpand(True)
        self.props.font_desc = Pango.FontDescription('1') 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:7,代码来源:gcode_view.py

示例14: __init__

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def __init__(self, manager, parent=None):
		Gtk.Window.__init__(self, title=_("Backup"))
		self.set_border_width(10)
		self.set_icon_name("drive-harddisk")
		self.set_position(Gtk.WindowPosition.CENTER)

		if parent is not None:
			self.set_transient_for(parent)

		vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
		self.add(vbox)

		self.label = Gtk.Label(_("Ready."), xalign=0)
		self.label.set_justify(Gtk.Justification.LEFT)
		vbox.pack_start(self.label, False, False, 0)

		self.progressbar = Gtk.ProgressBar()
		vbox.pack_start(self.progressbar, False, False, 0)

		self.textview = Gtk.TextView()
		#self.textview.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(0, 0, 0))
		#self.textview.modify_text(Gtk.StateType.NORMAL, Gdk.Color(255, 255, 255))
		fontdesc = Pango.FontDescription("monospace")
		self.textview.modify_font(fontdesc)
		self.textview.set_editable(False)
		sw = Gtk.ScrolledWindow()
		sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
		sw.set_min_content_height(200)
		sw.add(self.textview)
		exp = Gtk.Expander()
		exp.set_label(_("Details"))
		exp.add(sw)
		vbox.pack_start(exp, True, True, 0)

		hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
		vbox.add(hbox)
		self.close_button = Gtk.Button(_("Close"))
		self.close_button.connect("clicked", self.on_close_clicked)
		hbox.pack_end(self.close_button, False, False, 0)

		self.manager = manager 
开发者ID:emersion,项目名称:bups,代码行数:43,代码来源:gtk.py

示例15: ScrolledSourceView

# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import FontDescription [as 别名]
def ScrolledSourceView(text=None, syntax=None):
	'''If GTKSourceView was successfullly loaded, this generates a SourceView and
	initializes it. Otherwise ScrolledTextView will be used as a fallback.

	@param text: initial text to show in the view
	@param syntax: this will try to enable syntax highlighting for the given
	language. If None, no syntax highlighting will be enabled.
	@returns: a 2-tuple of a window and a view.
	'''
	if GtkSource:
		gsvbuf = GtkSource.Buffer()
		if syntax:
			gsvbuf.set_highlight_syntax(True)
			language_manager = GtkSource.LanguageManager()
			gsvbuf.set_language(language_manager.get_language(syntax))
		if text:
			gsvbuf.set_text(text)
		textview = GtkSource.View()
		textview.set_buffer(gsvbuf)
		textview.set_property("show-line-numbers", True)
		textview.set_property("auto-indent", True)
		font = Pango.FontDescription('Monospace')
		textview.modify_font(font)
		textview.set_property("smart-home-end", True)
		window = ScrolledWindow(textview)
		return (window, textview)
	else:
		return ScrolledTextView(text=text, monospace=True) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:30,代码来源:widgets.py


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