我的代码看起来像
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'该方法被称为rectangle in PyGTK ( cairo.Context和pango.Context)。
但是我在gtk3 C文档中搜索过,看起来应该是draw_rectangle
它们都不存在于Python中
发布于 2013-09-15 03:01:39
我错了
rectangle在cairo.Context中存在,但在pango.Context中不存在
我使用pango.Context是因为我在cairo.Context找不到show_layout
现在我看到这个方法也不在pango.Context对象中
我们必须使用无界方法PangoCairo.show_layout
摘要:
cr = self.get_window().cairo_create()
cr.rectangle(0, 0, w, h)
PangoCairo.show_layout(cr, layout)https://stackoverflow.com/questions/18799675
复制相似问题