[pygtk] How to do_size_allocate properly in a gtk.Viewport subclass?

Joel Hedlund yohell at ifm.liu.se
Fri Oct 24 00:07:06 WST 2008


Joel Hedlund wrote:
> Now, my real gripe is that zooming looks "twitchy" for small widgets 
> with the widget-in-table-in-viewport solution, and that will be painful 
> for users to look at. I'm hoping I've done some stupid oversight 
> somewhere (help?). Maybe that will go away if you glue the widget 
> topleft somehow?

Fixed; swapping out the table for a gtk.Alignment().

def make_revised_suggestion_window():
     d = MyDrawingarea()
     d.set_size_request(100, 100)
     a = gtk.Alignment()
     a.add(d)
     z = ZoomWindow()
     z.add_with_viewport(a)
     w = gtk.Window()
     w.add(z)
     w.set_size_request(200, 200)
     w.connect('destroy', gtk.main_quit)
     w.set_title('pygtk list suggestion')
     w.show_all()

This is close enough for jazz, so many thanks for putting me on the 
right track!

About the twitching:
At first I thought it twitched because the view was redrawn directly 
after the size change, and then got redrawn again after the table 
repositioned the size-changed widget, but after some experimentation I'm 
not so sure anymore. I may have caused the twitch myself by drawing an 
eye-unfriendly pattern on my test widget. Because if I draw a simple red 
rectangle instead, the transition is smooth.

So don't draw concentric circles on your test widgets, kids!

Again thanks for your help!
/Joel


More information about the pygtk mailing list