On Thu, 2008-08-14 at 11:53 +0200, Nati B wrote:
> Hi,
> I've just started using the bindings for PyClutter 0.8, and it seems
> very nice.
> However, due to lack of documentation, I'll raise my questions here
> and hopefully someone will have answers:
> 1. Why do I need to prefix my overriding methods with 'do_' - e.g.
> do_paint, do_get_preferred_width, etc.. ? When I define a method
> using the ordinary name (e.g. - 'paint' for example) it's not being
> called.
because that is the naming convention for python bindings of
gobject-based libraries.
patches to the documentation are very much welcome.
> 2. I relied on the clutter 0.8 C documentation for the size allocation
> mechanism of a custom actor, and tried to do the same in PyClutter.
> E.g. - I've overridden 'get_preferred_size' with my custom actor.
it surely is not what you need to do, and I wrote the C documentation.
you have to override:
def do_get_preferred_width (self, for_height):
return (min_width, natural_width)
def do_get_preferred_height (self, for_width):
return (min_height, natural_height)
def do_allocation (self, box, origin_changed):
> However, it's just not being called, and I have no idea why.
because there's no such virtual function as 'get_preferred_size' in the
C class - hence no way to override it. :-)
clutter.Actor.get_preferred_size() is just a wrapper around the
get_preferred_width() and get_preferred_height() methods - the
implementation looks like this:
def get_preferred_size (self):
request_mode = self.get('request-mode')
min_width = min_height = 0
natural_width = natural_height = 0
if request_mode == clutter.REQUEST_HEIGTH_FOR_WIDTH:
(min_width, natural_width) = self.get_preferred_width(-1)
(min_height, natural_height) =
self.get_preferred_height(natural_width)
elif request_mode == clutter.REQUEST_WIDTH_FOR_HEIGHT:
(min_height, natural_height) = self.get_preferred_height(-1)
(min_width, natural_width) = self.get_preferred_width(for_height)
return (min_width, min_height, natural_width, natural_height)
it's just a convenience call.
ciao,
Emmanuele.
--
Emmanuele Bassi, OpenedHand Ltd.
Unit R, Homesdale Business Centre
216-218 Homesdale Rd., Bromley - BR12QZ
http://www.o-hand.com
--
To unsubscribe send a mail to [EMAIL PROTECTED]