[pygtk] Writting a widget with native scrolling support

Gustavo J. A. M. Carneiro gjc at inescporto.pt
Tue Oct 21 23:07:08 WST 2008


http://www.daa.com.au/pipermail/pygtk/2006-January/011668.html

On Mon, 2008-10-20 at 21:20 +0200, Laszlo Nagy wrote:
> I want to write an owner-drawn widget (using Cairo) with native 
> scrolling capabilities. Let's say this widget has a get_hadjustment() 
> and a get_vadjustment() method. Scrolling inside the widget is already 
> implemented. E.g. the widget draws different things on its surface, 
> depending on the values of its adjustments.
> 
> I would like to add this widget to a ScrolledWindow. Here is what I do:
> 
>         # Create an owner drawn widget with native scrolling capabilites.
>         w = MyTable()
>        
>         # Create a ScrolledWindow
>         # This will share the adjustments between the scrollbars
>         # and the w widget.
>         sw = gtk.ScrolledWindow(
>             hadjustment=w.get_hadjusment(),
>             vadjustment=w.get_vadjusment()
>         )
>         # Add scrollable child widget to scrolled window.
>         sw.add(w)
> 
> 
> When starting my program, I get this message:
> 
> main.py:44: GtkWarning: gtk_scrolled_window_add(): cannot add non 
> scrollable widget use gtk_scrolled_window_add_with_viewport() instead
>   sw.add(w)
> 
> I wonder why it thinks that this is a non-scrollable widget? Should I 
> define some special slots for gtk to think this widget is scrollable? 
> I'm sorry but I could not find documentation about this.  Of course you 
> do not need to explain everything, just please point me to the right 
> place in the pygtk docs, or just give some hints how to do it.
> 
> Thank you,
> 
>    Laszlo
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
-- 
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
"The universe is always one step beyond logic" -- Frank Herbert



More information about the pygtk mailing list