Chris wrote:

Hi.

I'm trying to use a 2nd gtk drawingarea as a back buffer and flip the screens during an expose event. Trouble is, none of the expose event handlers seem to call my code, which, as a test, is

def expose_event(self,widget):
   print "test expose"

I've tried connecting that to the expose event of the GtkDrawingArea, the GtkScrolledWindow that it's wrapped in, and the GtkWindow that holds it - all to no avail.



Can't tell w/o more code. Here's the base class that I use for handling all the non app-specific details of GtkDrawingArea. It operates on an app-specific content object which needs to supply a few functions (add_callback, remove_callback, render, adjust_to_bounds) and a property (min_size). I am attaching it because I know it works, so you can compare it to yours and see what it does that yours doesn't.


class DrawingAreaContentController(object):
   def __init__(self, widget):
       self.content = None
       self.actual_size = (100,100)
       self.widget = widget
       self.widget.connect("expose-event", self.on_expose)
       self.widget.connect("configure-event", self.on_configure)
       self.widget.connect_after("realize", self.on_configure)
       self.content_prev_size = None

   def on_expose(self, widget, event):
       if self.content:
           area = event.area
           self.content.render(widget.window, area)

def do_adjust(self):
if self.content:
self.content.adjust_to_bounds(self.actual_size)
if self.content.min_size:
if self.content_prev_size != self.content.min_size:
self.content_prev_size = self.content.min_size
self.widget.set_size_request(self.content.min_size[0], self.content.min_size[1])
def on_configure(self, *args):
self.actual_size = self.widget.window.get_size()
self.do_adjust()
def set_content(self, obj):
if self.content:
self.content.remove_callback(self.content_updated)
self.content = obj
if self.content:
self.content.add_callback(self.content_updated)
self.do_adjust()
self.widget.queue_draw()


def content_updated(self, content):
if content == self.content:
self.widget.queue_draw()


_______________________________________________
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