2006-09-10 23:50:07 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
|
|
|
|
from sugar.session.UITestSession import UITestSession
|
|
|
|
|
|
|
|
session = UITestSession()
|
|
|
|
session.start()
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import goocanvas
|
|
|
|
|
2006-10-04 00:55:20 +02:00
|
|
|
from sugar.graphics.iconcolor import IconColor
|
|
|
|
from sugar.graphics.IconItem import IconItem
|
|
|
|
from sugar.graphics.CanvasView import CanvasView
|
|
|
|
from sugar.graphics.CanvasBox import CanvasBox
|
|
|
|
from sugar.graphics.Grid import Grid
|
2006-09-10 23:50:07 +02:00
|
|
|
|
|
|
|
def _new_icon_clicked_cb(icon):
|
|
|
|
box.remove_child(icon)
|
|
|
|
|
|
|
|
def _icon_clicked_cb(icon):
|
|
|
|
icon = IconItem(color=IconColor(), icon_name='activity-groupchat')
|
|
|
|
icon.connect('clicked', _new_icon_clicked_cb)
|
2006-09-13 14:11:12 +02:00
|
|
|
box.set_constraints(icon, 3, 3)
|
2006-09-10 23:50:07 +02:00
|
|
|
box.add_child(icon, 0)
|
|
|
|
|
2006-09-13 13:50:00 +02:00
|
|
|
model = goocanvas.CanvasModelSimple()
|
|
|
|
root = model.get_root_item()
|
2006-09-10 23:50:07 +02:00
|
|
|
|
2006-09-13 13:50:00 +02:00
|
|
|
grid = Grid()
|
|
|
|
|
|
|
|
box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1)
|
2006-09-13 14:11:12 +02:00
|
|
|
grid.set_constraints(box, 3, 3)
|
2006-09-13 13:50:00 +02:00
|
|
|
root.add_child(box)
|
2006-09-10 23:50:07 +02:00
|
|
|
|
|
|
|
rect = goocanvas.Rect(fill_color='red')
|
2006-09-13 14:11:12 +02:00
|
|
|
box.set_constraints(rect, 3, 3)
|
2006-09-10 23:50:07 +02:00
|
|
|
box.add_child(rect)
|
|
|
|
|
|
|
|
icon = IconItem(color=IconColor(), icon_name='activity-web')
|
|
|
|
icon.connect('clicked', _icon_clicked_cb)
|
2006-09-13 14:11:12 +02:00
|
|
|
box.set_constraints(icon, 3, 3)
|
2006-09-10 23:50:07 +02:00
|
|
|
box.add_child(icon)
|
|
|
|
|
|
|
|
icon = IconItem(color=IconColor(), icon_name='activity-groupchat')
|
2006-09-13 14:11:12 +02:00
|
|
|
box.set_constraints(icon, 3, 3)
|
2006-09-10 23:50:07 +02:00
|
|
|
box.add_child(icon)
|
|
|
|
|
|
|
|
window = gtk.Window()
|
|
|
|
window.connect("destroy", lambda w: gtk.main_quit())
|
|
|
|
window.show()
|
|
|
|
|
|
|
|
canvas = CanvasView()
|
|
|
|
canvas.show()
|
|
|
|
window.add(canvas)
|
2006-09-13 13:50:00 +02:00
|
|
|
canvas.set_model(model)
|
2006-09-10 23:50:07 +02:00
|
|
|
|
|
|
|
gtk.main()
|