蟒蛇& gtk3 - 缺少cairo_context.show_layout方法

时间:2013-09-14 08:06:33

标签: python gtk cairo gtk3 pango

我的代码看起来像

from gi.repository import PangoCairo
from gi.repository import Gtk

class Column(Gtk.DrawingArea):
    getContext = lambda self: PangoCairo.create_context(self.get_window().cairo_create())

    ...

        cr = self.getContext()        
        cr.rectangle(0, 0, w, h)

我收到了这个错误:

AttributeError: 'Context' object has no attribute 'rectangle'

该方法在PyGTK中被称为rectangle(cairo.Context和pango.Context) 但我搜索了gtk3 C文档,看起来它应该是draw_rectangle
并且它们都不存在于Python

1 个答案:

答案 0 :(得分:0)

我错了 rectangle中存在cairo.Context,但pango.Context

中没有pango.Context

我使用了show_layout,因为我在cairo.Context中找不到pango.Context了 现在我看到该方法不在PangoCairo.show_layout对象中 我们必须使用无界方法cr = self.get_window().cairo_create() cr.rectangle(0, 0, w, h) PangoCairo.show_layout(cr, layout)

要点:

{{1}}