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

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

 




Thanks so much Emmanuele!

I actually had "return True" on my real code but I wasn't using the right cr.

-RSM


On 05/06/2015 12:07 PM, Emmanuele Bassi wrote:
Hi;

On 6 May 2015 at 10:35, rsm <rsm@xxxxxxx> wrote:
         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()
The implementation of the GtkWidget::draw signal handler is wrong.

The draw signal provides you with the Cairo context to draw on; you do
not need (and actually you mustn't) use Gdk.Window.cairo_create().

You're also passing the drawing area widget, but that's the widget
that emits the signal, so it's pointless.

A valid draw signal implementation is:

   def draw(self, widget, cr):
       cr.rectangle(x, y, width, height)
       cr.set_source_rgb(red, green, blue)
       cr.fill()
       return True

You should read the API reference for GTK+ 3.x:

   https://developer.gnome.org/gtk/stable

as well as the Python API reference:

   http://lazka.github.io/pgi-docs/#Gtk-3.0

Ciao,
  Emmanuele.


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux