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 py...@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
--
Gustavo J. A. M. Carneiro
<g...@inescporto.pt> <gus...@users.sourceforge.net>
"The universe is always one step beyond logic" -- Frank Herbert
"For custom widgets, check the method gtk.Widget.set_set_scroll_adjustments_signal(signal_name)"
But this method only has a signal_name parameter. I do not see how I
could use it for specifying my adjustments and making my widget support
scrolling natively?
(Also that was written in 2006, probably it is outdated.)
Thanks,
It is not outdated. See
http://library.gnome.org/devel/gtk/2.14/GtkWidget.html
GtkWidgetClass
typedef struct {
/* The object class structure needs to be the first
* element in the widget class structure in order for
* the class mechanism to work correctly. This allows a
* GtkWidgetClass pointer to be cast to a GtkObjectClass
* pointer.
*/
GtkObjectClass parent_class;
guint activate_signal;
guint set_scroll_adjustments_signal;
} GtkWidgetClass;
activate_signal The signal to emit when a widget of this class
is activated, gtk_widget_activate() handles the emission.
Implementation of this signal is optional.
set_scroll_adjustment_signal This signal is emitted when a
widget of this class is added to a scrolling aware parent,
gtk_widget_set_scroll_adjustments() handles the emission.
Implementation of this signal is optional.
gtk.Widget.set_set_scroll_adjustments_signal is PyGtk's equivalent to
Gtk+/C setting the field set_scroll_adjustments_signal of the
GtkWidgetClass of your widget. Basically you have to define a signal
"my-signal" in your widget that accepts two gtk.Adjustment objects as
parameters, then do
MyClass.set_set_scroll_adjustments_signal("my-signal"). Of course you
still need to implement the scrolling by monitoring the adjustments and
updating the widget's view accordingly, but after that you can add your
widget to a scrolled window.
>
> Thanks,
>
> Laszlo
>
>
--
Gustavo J. A. M. Carneiro
<g...@inescporto.pt> <gus...@users.sourceforge.net>
"The universe is always one step beyond logic" -- Frank Herbert
_______________________________________________