Write a GridModel, with correct size and layout, and use it

This commit is contained in:
Marco Pesenti Gritti
2006-09-07 19:03:40 +02:00
parent fbc7bd8b97
commit 5988a89517
3 changed files with 35 additions and 12 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ class CanvasWindow(gtk.Window):
gtk.Window.__init__(self)
self._view = goocanvas.CanvasView()
self._view.set_model(model)
self._view.set_model(model.get())
self.add(self._view)
self._view.show()
+30
View File
@@ -0,0 +1,30 @@
import goocanvas
from sugar.canvas.GridLayout import GridGroup
# FIXME model subclassing doesn't work in pygoocanvas
class GridModel:
def __init__(self, bg_color):
self._model = goocanvas.CanvasModelSimple()
self._width = 800
self._height = 600
item = goocanvas.Rect(width=self._width, height=self._height,
line_width=0, fill_color=bg_color)
self._model.get_root_item().add_child(item)
self._root = GridGroup()
self._root.props.width = self._width
self._root.props.height = self._height
self._model.get_root_item().add_child(self._root)
def add(self, child):
self._root.add_child(child)
def get(self):
return self._model
def get_layout(self):
return self._root.get_layout()