python&;gtk3-缺少cairo_context.show_布局方法

python&;gtk3-缺少cairo_context.show_布局方法,python,gtk,cairo,gtk3,pango,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()

我的代码看起来像

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\u rectangle

它们都不存在于Python中

我错了
矩形
出现在
cairo.Context中
但不在
pango.Context中

我使用了
pango.Context
,因为在
cairo.Context

现在我看到该方法也不在
pango.Context
object中
我们必须使用无界方法
PangoCairo.show_布局

总结:

cr = self.get_window().cairo_create()
cr.rectangle(0, 0, w, h)
PangoCairo.show_layout(cr, layout)

嗯,我认为必须使用未绑定的方法是一个bug。