Fwd: GTK3+ (3.14) drawing area on scrolledwindow. Bug?




Hello,

    Somme days ago I posted over SO* because I'm having some problems to render a drawing area placed over  a scrolled window.
I'm starting to think that I may have found a bug and I'd like to have someone else's option. The code seems to be no problem over pyGtk2,
but it seems to don't work over pygobject. (I'd really like to find a solution for GTK 3.14)

*SO link: http://stackoverflow.com/questions/29989386/gtk3-3-14-drawing-area-on-scrolledwindow


pyGobject Code:
from gi.repository import Gtk, Gdk
import cairo

class Test(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)
        sw=Gtk.ScrolledWindow()
        vp=Gtk.Viewport()
        box=Gtk.VBox()

        vp.set_size_request(100,100)

        for i in range(3):
            da=Gtk.DrawingArea()
            da.connect("draw", self.draw, [0.3, 0.4, 0.6], da)
            da.set_size_request(100,100)
            box.add(da)

        sw.add(vp)
        vp.add(box)        
        self.add(sw)
        self.show_all()

    def draw(self, widget, event, color, da):
        cr = widget.get_property('window').cairo_create()
        cr.rectangle(0, 0, 100, 100)
        cr.set_source_rgb(color[0], color[1], color[2])
        cr.fill()

main=Test()
Gtk.main()

pyGtk2 code:

import gtk, cairo

class Test(gtk.Window):

    def __init__(self):
        gtk.Window.__init__(self)
        sw=gtk.ScrolledWindow()
        vp=gtk.Viewport()
        box=gtk.VBox()

        for i in range(3):
            da=gtk.DrawingArea()
            da.connect("expose-event", self.draw, [0.3, 0.4, 0.6], da)
            box.add(da)

        sw.add(vp)
        vp.add(box)        
        self.add(sw)
        self.show_all()

    def draw(self, widget, event, color, da):
        cr = widget.get_property('window').cairo_create()
        cr.rectangle(0, 0, 100, 100)
        cr.set_source_rgb(color[0], color[1], color[2])
        cr.fill()

main=Test()
gtk.main()

Thanks so much for the help!
-RSM





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]