Clutter Group
#!/usr/bin/env python
#
# [SNIPPET_NAME: Clutter Group]
# [SNIPPET_CATEGORIES: Clutter]
# [SNIPPET_DESCRIPTION: Shows how to group actors so that animations will effect them all uniformly]
# [SNIPPET_AUTHOR: Andy Breiner <[email protected]>]
# [SNIPPET_LICENSE: GPL]
# [SNIPPET_DOCS: http://clutter-project.org/docs/pyclutter/stable/]
import clutter
class ClutterGroup:
def __init__ (self):
# Create stage and set its properties.
self.stage = clutter.Stage()
self.stage.set_color(clutter.color_from_string("Black"))
self.stage.set_size(500, 400)
self.stage.set_title("Clutter Group")
self.stage.connect("destroy",clutter.main_quit)
# Create a group
group = clutter.Group()
# Create a label and its properties.
# It will be 10,20 from the top left of the group
color = clutter.Color(0xff, 0xcc, 0xcc, 0xdd)
label = clutter.Text()
label.set_font_name("Mono 18")
label.set_text("Rectangle")
label.set_color(color)
label.set_position(10, 20)
rect = clutter.Rectangle()
rect.set_color(clutter.Color(0xcc, 0xcc, 0xcc, 0xcc))
rect.set_size(50, 50)
rect.set_position(50, 50)
# Add label and rect to group.
group.add(label)
group.add(rect)
self.stage.add(group)
# Animate the group to show how the elements move together
animation = group.animate(clutter.AnimationMode(clutter.LINEAR),
1000,
"x", 200.0,
"y", 200.0)
# Start main clutter loop.
self.stage.show_all()
clutter.main()
if __name__ == '__main__':
main = ClutterGroup()