A Sex, 2003-12-05 �s 18:13, Jean-Baptiste Cazier escreveu:
> hi !
> 
> After further investigation it seems that the routine called by my expose_event 
> signal is generating itself new expose_event...
> 
> To avoid that effect I would like to block the signal when entering the routine and 
> unblock it while leaving
> but I have problem transferring the event id through the routine itself and to knwo 
> to what I should apply it to
> How should i use signal_handler_block ?
> 
> I would like to do somethhing like 
> ...
>     self.area = gtk.DrawingArea()
>     self.area.add_events(gtk.gdk.POINTER_MOTION_MASK)
>     self.area.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
>     self.area.add_events(gtk.gdk.BUTTON_PRESS_MASK )
>     singal_id=self.area.connect("expose-event", self.area_expose_cb)
>     print "id is ", signal_id
> ...
> 
>     def area_expose_cb(self, area, event):
>       """ Update the DrawingArea """
> 
>       area.signal_handler_block(signal_id)
>       ...
>       Do something on the Drawing Area
>       ...
>       area.signal_handler_unblock(signal_id)  
>       return gtk.TRUE
>  
> Any help would be appreciated

  Why complicate? Why not simply discard recursive expose events?  I
must say I find it very strange that gtk is sending expose events
recursively.  I _think_ that the only way this could happen would be if
you were running the gtk main loop (or dialog.run) inside the expose
event handler.  This would be a Bad Idea (TM)!

  Anyway, an alternative to signal handler blocking, which doesn't seem
to be working (I read down the thread), would be a simple trick of
locking:

    def area_expose_cb(self, area, event):
      """ Update the DrawingArea """
      if self.__area_expose_cb_lock: return True
      self.__area_expose_cb_lock = True
      ...
      Do something on the Drawing Area
      ...
      self.__area_expose_cb_lock = False
      return gtk.TRUE

  One more thing.  If your struggling with complex drawings, you might
want to use the gnome.Canvas widget instead.

  Regards.

-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to