I need to retrieve the position of a Gtk::Widget
relative to its parent, a Gtk::Table
. Most sources (e.g. http://library.gnome.org/devel/gtk-faq/stable/x642.html) say that one needs to call Gtk::Widget::get_allocation()
. However, the returned Gtk::Allocation
object always contains x = -1
, y = -1
, width = 1开发者_如何学Python
, height = 1
.
I have to note that this happens before the Gtk::Table
object is actually exposed and rendered. A call to show_all_children()
or check_resize()
, which I would expect to recalculate child widget geometry, doesn't help.
What am I doing wrong? Thanks in advance.
You could try calling gtk_widget_realize()
on the top-level GtkTable.
Another approach, as suggested in the documentation I linked, is to attach a handler to the GtkWidget::expose-event
signal.
精彩评论