示例#1
0
 def draw(self, shape):
     # Method drawing a shape on the canvas.
     self.__canvas.delete(self.__tmp_rendered)
     rendered_shape = None
     if shape['type'] == 'rectangle' and shape['mode'] == 'normal':
         rendered_shape = Rectangle(shape)
     elif shape['type'] == 'rectangle' and shape['mode'] == 'straight':
         rendered_shape = Square(shape)
     elif shape['type'] == 'oval' and shape['mode'] == 'normal':
         rendered_shape = Oval(shape)
     elif shape['type'] == 'oval' and shape['mode'] == 'straight':
         rendered_shape = Circle(shape)
     elif shape['type'] == 'line' and shape['mode'] == 'normal':
         rendered_shape = Line(shape)
     elif shape['type'] == 'line' and shape['mode'] == 'straight':
         rendered_shape = Diagonal(shape)
     shape_id = rendered_shape.draw_on(self.__canvas)
     return shape_id