您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

华为mate50系列发布会,明星艳史系列1-300

来源:互联网 浏览:86次 时间:2023-04-08

PangoLayout Methods 例子

Pango.Layout

Pango.Layout结构表示整个文本段落。一般使用Pango.Context来进行初始化,使用Pango.Layout.set_text(text, 便宜美国vps length)方法来设置文本;或者使用Widget.create_pango_layout(text)方法来创建,并设置该字符串的属性。

设置完成后,格式化的文本段落就可以从对象中获取,布局将会渲染呈现出来。

Methods 方法修饰词方法名及参数staticnew (context)context_changed ()copy ()get_alignment ()get_attributes ()get_auto_dir ()get_baseline ()get_character_count ()get_context ()get_cursor_pos (index_)get_ellipsize ()get_extents ()get_font_description ()get_height ()get_indent ()get_iter ()get_justify ()get_line (line)get_line_count ()get_line_readonly (line)get_lines ()get_lines_readonly ()get_log_attrs ()get_log_attrs_readonly ()get_pixel_extents ()get_pixel_size ()get_serial ()get_single_paragraph_mode ()get_size ()get_spacing ()get_tabs ()get_text ()get_unknown_glyphs_count ()get_width ()get_wrap ()index_to_line_x (index_, trailing)index_to_pos (index_)is_ellipsized ()is_wrapped ()move_cursor_visually (strong, old_index, old_trailing, direction)set_alignment (alignment)set_attributes (attrs)set_auto_dir (auto_dir)set_ellipsize (ellipsize)set_font_description (desc)set_height (height)set_indent (indent)set_justify (justify)set_markup (markup, length)set_markup_with_accel (markup, length, accel_marker)set_single_paragraph_mode (setting)set_spacing (spacing)set_tabs (tabs)set_text (text, length)set_width (width)set_wrap (wrap)xy_to_index (x, y) 例子


代码:

#!/usr/bin/env python3# Created by xiaosanyu at 16/7/6# section 140TITLE = "Layout"DESCRIPTION = """Pango layout is an object representing a paragraph of text with attributes."""import gigi.require_version("Gtk", "3.0")gi.require_version('PangoCairo', '1.0')from gi.repository import Gtk, Gdk, Pango, PangoCairoimport cairolyrics = """Meet you downstairs in the bar and heardyour rolled up sleeves and your skull t-shirtYou say why did you do it with him today?and sniff me out like I was Tanqueraycause you're my fella, my guyhand me your stella and flyby the time I'm out the dooryou tear men down like Roger MooreI cheated myselflike I knew I wouldI told ya, I was troubleyou know that I'm no good"""class Area(Gtk.DrawingArea): def __init__(self): super(Area, self).__init__() self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(16400, 16400, 16440)) self.connect("draw", self.draw) def draw(self, da, cr): font_desc = Pango.FontDescription('Sans 15') layout = da.create_pango_layout(lyrics) layout.set_markup("<span foreground=\"#FF00FF\">%s</span>" % layout.get_text(), -1) layout.set_width(Pango.SCALE * self.get_allocation().width) layout.set_spacing(Pango.SCALE * 3) layout.set_alignment(Pango.Alignment.CENTER) layout.set_font_description(font_desc) # PangoCairo.layout_path(cr, layout) # cr.set_source_rgb(0.5, 0, 0) # cr.fill() PangoCairo.show_layout(cr, layout) return Trueclass 老实的帆布鞋(Gtk.Window): def __init__(self): super(老实的帆布鞋, self).__init__() self.connect("destroy", Gtk.main_quit) self.set_title("You know I'm no Good") self.add(Area()) self.set_size_request(300, 300) self.move((self.get_screen().width() - 300) / 2, (self.get_screen().height() - 300) / 2) self.show_all()def main(): 老实的帆布鞋() Gtk.main()if __name__ == '__main__': main()





代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728

78134841