我的代码看起来像
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
答案 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}}