On Thu, Jun 13, 2013 at 9:54 PM, Kip Warner <k...@thevertigo.com> wrote: > > What you can do to (try to) prevent that situation is to set the widget to > > do "height for width" allocation, and override > > get_preferred_height_for_width() to honor your aspect ratio. In some > > situations of course the toolkit won't be able to perfectly honor the > > allocation request, so be sure not to scale out of bounds no matter what. > > Right. What I will do is resize to exactly what is passed into my > do_size_allocate() override since that size should theoretically meet > the aspect ratio I am maintaining via my > do_get_preferred_height_for_width() override. > def do_get_preferred_height_for_width(self, width): > return (width / self._aspectRatio) > > def do_get_request_mode(self): > return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH > > ...but something very interesting happens immediately after the return > in do_get_preferred_height_for_width(). I get an assertion fail buried > deep somewhere in python-gi...
I suspect something weird is happening because you have the wrong function signature. I can't find any reference to the basic widget methods on the python gtk documentation website, but the C signature is: void gtk_widget_get_preferred_height_for_width (GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height); So try: def do_get_preferred_height_for_width(self, width, minimum_height, natural_height): minimum_height = width / self._aspectRatio natural_height = width / self._aspectRatio If that doesn't work, try and find out how the python gintrospection stuff deals with out parameters. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list