0

My code looks like

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)

And I get this error:

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

The method was called rectangle in PyGTK (both cairo.Context and pango.Context)
But I searched in gtk3 C documentations and it seems It should be draw_rectangle
And none of them exist in Python

1 Answer 1

0

I was wrong
rectangle is present in cairo.Context but not in pango.Context

I used pango.Context because I couldn't find show_layout in cairo.Context
Now I see the method is not in pango.Context object either
We have to use unbounded method PangoCairo.show_layout

Summary:

cr = self.get_window().cairo_create()
cr.rectangle(0, 0, w, h)
PangoCairo.show_layout(cr, layout)
Sign up to request clarification or add additional context in comments.

1 Comment

Hmm. I'd consider having to use the unbound method to be a bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.