Hi all,
I'm not sure if this the appropriate list for this discussion so please let
me know if this is off-topic.
I'm trying out Clutter and I have managed to make some simple animations but
as I'm trying to make an animation as a response to a key event I seem to be
out of luck? Can anyone tell me why this code snippet isn't working?
This is with Clutter 0.4.2 in Gutsy.
#! /usr/bin/python
import clutter
def key_event(stage, event):
timeline = clutter.Timeline(100, 26)
alpha = clutter.Alpha(timeline, clutter.sine_func )
path_forward = clutter.BehaviourPath(alpha, ((0, 0), (100, 100)))
# Up
if event.keyval == 65362:
menu = stage.get_nth_child(0)
path_forward.apply(menu)
timeline.start ()
# q
if event.keyval == 113:
clutter.main_quit()
return True
def build_scene():
label = clutter.Label()
label.set_text('Some label')
label.show ()
menu = clutter.HBox()
menu.add(label)
menu.set_position(0, 0)
menu.show()
stage = clutter.stage_get_default()
stage.set_size(300, 300)
stage.set_color(clutter.color_parse ("#7F7F7F"))
stage.add(menu)
stage.show()
return stage
def main():
stage = build_scene()
stage.connect("key-press-event", key_event)
clutter.main ()
if __name__ == '__main__':
main()
Thanks,
Johan