Beginnings of a simple scene API. Inspired opened-hand's Clutter

master
Marco Pesenti Gritti 18 years ago
parent 2aa23cfa42
commit a02313d85a

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

@ -0,0 +1,39 @@
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
from sugar.scene.Stage import Stage
from sugar.scene.Group import Group
from sugar.scene.PixbufActor import PixbufActor
def drawing_area_expose_cb(widget, event, stage):
stage.render(widget.window)
stage = Stage()
pixbuf = gtk.gdk.pixbuf_new_from_file('background.png')
stage.add(PixbufActor(pixbuf))
icons_group = Group()
i = 1
while i <= 5:
pixbuf = gtk.gdk.pixbuf_new_from_file('activity%d.png' % i)
icons_group.add(PixbufActor(pixbuf))
i += 1
stage.add(icons_group)
window = gtk.Window()
window.set_default_size(640, 480)
drawing_area = gtk.DrawingArea()
drawing_area.connect('expose_event', drawing_area_expose_cb, stage)
window.add(drawing_area)
drawing_area.show()
window.show()
gtk.main()

@ -0,0 +1,17 @@
class Actor:
def __init__(self):
self._x = 0
self._y = 0
self._width = -1
self._height = -1
def set_position(self, x, y):
self._x = x
self._y = y
def set_size(self, width, height):
self._width = width
self._height = height
def render(self, window):
pass

@ -0,0 +1,15 @@
from sugar.scene.Actor import Actor
class Group(Actor):
def __init__(self):
self._actors = []
def add(self, actor):
self._actors.append(actor)
def remove(self, actor):
self._actors.remove(actor)
def render(self, drawable):
for actor in self._actors:
actor.render(drawable)

@ -0,0 +1,13 @@
import gtk
from sugar.scene.Actor import Actor
class PixbufActor(Actor):
def __init__(self, pixbuf):
Actor.__init__(self)
self._pixbuf = pixbuf
def render(self, drawable):
gc = gtk.gdk.GC(drawable)
drawable.draw_pixbuf(gc, self._pixbuf, 0, 0, self._x, self._y)

@ -0,0 +1,5 @@
from sugar.scene.Group import Group
class Stage(Group):
def __init__(self):
Group.__init__(self)
Loading…
Cancel
Save