2006-07-22 11:54:27 +02:00
|
|
|
#!/usr/bin/python
|
2006-07-22 13:48:47 +02:00
|
|
|
import math
|
2006-07-22 11:54:27 +02:00
|
|
|
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
from sugar.scene.Stage import Stage
|
|
|
|
from sugar.scene.Group import Group
|
2006-07-24 12:15:52 +02:00
|
|
|
from sugar.scene.View import View
|
2006-07-22 11:54:27 +02:00
|
|
|
from sugar.scene.PixbufActor import PixbufActor
|
2006-07-22 12:28:59 +02:00
|
|
|
from sugar.scene.CircleLayout import CircleLayout
|
2006-07-22 13:48:47 +02:00
|
|
|
from sugar.scene.Timeline import Timeline
|
2006-07-22 11:54:27 +02:00
|
|
|
|
2006-07-22 13:48:47 +02:00
|
|
|
def __next_frame_cb(timeline, frame_num, group):
|
2006-07-22 14:32:04 +02:00
|
|
|
angle = math.pi * 2 * frame_num / timeline.get_n_frames()
|
2006-07-22 13:48:47 +02:00
|
|
|
group.get_layout().set_angle(angle)
|
|
|
|
group.do_layout()
|
|
|
|
|
|
|
|
def __completed_cb(timeline, group):
|
|
|
|
group.get_layout().set_angle(0)
|
|
|
|
group.do_layout()
|
|
|
|
|
2006-07-22 11:54:27 +02:00
|
|
|
stage = Stage()
|
|
|
|
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file('background.png')
|
|
|
|
stage.add(PixbufActor(pixbuf))
|
|
|
|
|
|
|
|
icons_group = Group()
|
2006-07-24 11:01:25 +02:00
|
|
|
icons_group.set_position(100, 100)
|
2006-07-22 11:54:27 +02:00
|
|
|
|
|
|
|
i = 1
|
|
|
|
while i <= 5:
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file('activity%d.png' % i)
|
|
|
|
icons_group.add(PixbufActor(pixbuf))
|
|
|
|
i += 1
|
|
|
|
|
2006-07-22 12:28:59 +02:00
|
|
|
layout = CircleLayout(100)
|
2006-07-22 13:48:47 +02:00
|
|
|
icons_group.set_layout(layout)
|
2006-07-22 12:28:59 +02:00
|
|
|
|
2006-07-22 11:54:27 +02:00
|
|
|
stage.add(icons_group)
|
|
|
|
|
|
|
|
window = gtk.Window()
|
|
|
|
window.set_default_size(640, 480)
|
|
|
|
|
2006-07-24 12:15:52 +02:00
|
|
|
view = View(stage)
|
|
|
|
window.add(view)
|
|
|
|
view.show()
|
2006-07-22 11:54:27 +02:00
|
|
|
|
|
|
|
window.show()
|
|
|
|
|
2006-07-24 11:01:25 +02:00
|
|
|
timeline = Timeline(stage, 200)
|
2006-07-22 13:48:47 +02:00
|
|
|
timeline.connect('next-frame', __next_frame_cb, icons_group)
|
|
|
|
timeline.connect('completed', __completed_cb, icons_group)
|
|
|
|
timeline.start()
|
|
|
|
|
2006-07-22 11:54:27 +02:00
|
|
|
gtk.main()
|