Tengo una pequeña aplicación que usa un DrawingArea
para dibujar un mapa simple usando PyGObject
y GTK3
.Cómo dibujar un GdkPixbuf usando GTK3 y PyGObject
cargo un Pixbuf
usando
from gi.repository import Gtk, GdkPixbuf
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("logo.png", 25, 25)
y luego tratar de dibujar en el DrawingArea
's dibujar señal de evento
def draw(self, widget, context):
window = widget.get_window()
ctx = window.cairo_create()
ctx.set_source_pixbuf(pixbuf, 0, 0)
pero me sale el mensaje de error
"AttributeError: 'cairo.Context' object has no attribute 'set_source_pixbuf'"
Si estoy leyendo el Gtk2 to Gtk3 migration guide correctamente, esto debería funcionar. ¿Qué estoy haciendo mal?
¿Seguro que está recibiendo algo de vuelta de dibujable get_window ? – stark
Sí, obtengo un objeto '', por lo que se realiza el widget DrawingArea. Parece que no sé cómo se supone que funciona el dibujo de pixbufs en Gtk3. –
gnirx