2011-10-31 19:56:13 +01:00
|
|
|
from gi.repository import Gtk
|
|
|
|
|
|
|
|
from sugar3.graphics import animator
|
|
|
|
from sugar3.graphics.icon import Icon
|
|
|
|
from sugar3.graphics import style
|
|
|
|
|
2017-01-11 18:23:08 +01:00
|
|
|
from common import set_theme
|
|
|
|
set_theme()
|
|
|
|
|
2011-10-31 19:56:13 +01:00
|
|
|
|
|
|
|
class _Animation(animator.Animation):
|
2017-01-11 18:23:08 +01:00
|
|
|
|
2011-10-31 19:56:13 +01:00
|
|
|
def __init__(self, icon, start_size, end_size):
|
|
|
|
animator.Animation.__init__(self, 0.0, 1.0)
|
|
|
|
|
|
|
|
self._icon = icon
|
|
|
|
self.start_size = start_size
|
|
|
|
self.end_size = end_size
|
|
|
|
|
|
|
|
def next_frame(self, current):
|
|
|
|
d = (self.end_size - self.start_size) * current
|
|
|
|
self._icon.props.pixel_size = int(self.start_size + d)
|
|
|
|
|
|
|
|
|
|
|
|
def __animation_completed_cb(anim):
|
2018-03-01 12:58:56 +01:00
|
|
|
print('Animation completed')
|
2011-10-31 19:56:13 +01:00
|
|
|
|
2013-05-18 04:48:47 +02:00
|
|
|
|
2011-10-31 19:56:13 +01:00
|
|
|
w = Gtk.Window()
|
2017-01-11 18:23:08 +01:00
|
|
|
w.connect('delete-event', Gtk.main_quit)
|
2011-10-31 19:56:13 +01:00
|
|
|
|
2017-01-11 18:23:08 +01:00
|
|
|
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
2011-10-31 19:56:13 +01:00
|
|
|
w.add(box)
|
|
|
|
|
|
|
|
anim = animator.Animator(5)
|
|
|
|
anim.connect('completed', __animation_completed_cb)
|
|
|
|
|
|
|
|
my_icon = Icon(icon_name='go-next')
|
|
|
|
box.pack_start(my_icon, False, False, 0)
|
|
|
|
|
|
|
|
anim.add(_Animation(my_icon, style.STANDARD_ICON_SIZE, style.XLARGE_ICON_SIZE))
|
|
|
|
anim.start()
|
|
|
|
|
|
|
|
w.show_all()
|
|
|
|
|
|
|
|
Gtk.main()
|