Ejemplo n.º 1
0
 def finished(self):
     if self._other_turtle:
         from pylogo.ide import add_command, get_canvas
         canvas = get_canvas()
         x_origin, y_origin = 0, 0
         for x in self.seen_x_values:
             for y in self.seen_y_values:
                 add_command(canvas.create_oval,(x_origin+x-2,y_origin-y-2,x_origin+x+2,y_origin-y+2))
         for i,x in enumerate(self.seen_x_values):
             add_command(canvas.create_text(x_origin+x,y_origin-self.seen_y_values[0]+15,text=str(i)))
         for i,y in enumerate(self.seen_y_values):
             add_command(canvas.create_text(x_origin+self.seen_x_values[0]-15,y_origin-y,text=str(i)))
         add_command(canvas.update)
     for (old_x,old_y,new_x,new_y), op in self.operators.iteritems():
         old_x_grid = get_closest(old_x,self.seen_x_values)
         new_x_grid = get_closest(new_x,self.seen_x_values)
         old_y_grid = get_closest(old_y,self.seen_y_values)
         new_y_grid = get_closest(new_y,self.seen_y_values)
         sys.__stdout__.write("(%i,%i) %s (%i,%i) %s\n" % (old_x_grid,old_y_grid,op,new_x_grid,new_y_grid,op))
     sys.__stdout__.close()
Ejemplo n.º 2
0
 def postscript(self,filename):
     if self._other_turtle:
         from pylogo.ide import add_command, get_canvas
         canvas = get_canvas()
         width = canvas.winfo_width()
         height = canvas.winfo_height()
         if width <= 1:
             width = canvas['width']
         if height <= 1:
             height = canvas['height']
         x_origin, y_origin = 0, 0
         def printit():
             f = open(filename,"w")
             print >> f, canvas.postscript(
                 width=self.seen_x_values[-1]-self.seen_x_values[0]+35,
                 height=self.seen_y_values[-1]-self.seen_y_values[0]+35,
                 x=x_origin+self.seen_x_values[0]-25,
                 y=y_origin-self.seen_y_values[-1]-10
             )
             f.flush()
             f.close()
         add_command(printit)