Rework display code to avoid Scatter widget
authorNeil <neil@dip.sun.ac.za>
Sun, 14 Apr 2013 18:45:46 +0000 (20:45 +0200)
committerNeil <neil@dip.sun.ac.za>
Sun, 14 Apr 2013 18:45:46 +0000 (20:45 +0200)
erdslangetjie/editor/editor.py

index ecdbec7cc61f3c3cc36f65248d656042ba7a60ee..c2d2745559801cada06ce3fe2f042c4edfbf9ca9 100644 (file)
@@ -1,24 +1,23 @@
 import sys
 import os
 import kivy
-from erdslangetjie.data import filepath, load
-from erdslangetjie.level import Level
 
 kivy.require('1.6.0')
 
 from kivy.app import App
 from kivy.logger import Logger, LoggerHistory
 from kivy.uix.widget import Widget
-
 from kivy.uix.floatlayout import FloatLayout
-from kivy.uix.scatter import Scatter
 from kivy.graphics import Color, Rectangle
 
+from erdslangetjie.data import filepath, load
+from erdslangetjie.level import Level
+
 
 class EditorWindow(FloatLayout):
 
     def __init__(self, level):
-        super(EditorWindow, self).__init__()
+        super(EditorWindow, self).__init__(size=(960, 960))
         if os.path.exists(filepath(level)):
             level_data = load(level)
             self.level = level
@@ -44,10 +43,11 @@ class EditorWindow(FloatLayout):
         for tile_line in tiles:
             bx = 0
             for tile in tile_line:
-                node = Scatter(pos=(bx, by), size=(tile_size, tile_size))
+                node = Widget(size=(tile_size, tile_size), pos=(bx, by))
                 with node.canvas:
                     Color(1, 1, 1)
-                    Rectangle(size=node.size, texture=tile.texture)
+                    Rectangle(pos=node.pos, size=node.size,
+                            texture=tile.texture)
                 self.add_widget(node)
                 bx += tile_size
             by += tile_size