Write a GridModel, with correct size and layout, and use it
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user