2021年3月11日星期四

How to enlarge and reduce an already drawn lines, using certain buttons?

Suppose I have the following program made with Tkinter in Python, in which you can click to draw any shape.

import tkinter  canvas = tkinter.Canvas(width=500, height=500, bg='white')  canvas.pack()    line = ()  def draw():      canvas.delete('all')      if len(line) >= 4:          canvas.create_line(line, fill='red', width=2)  def newline(coordinates):      global line      line = line + (coordinates.x, coordinates.y)      draw()  canvas.bind('<Button-1>', newline)  

I have tried this for smaller image, but it didn't work.

def reduced():      line_reduced = ()      for i in newline:          line_reduced += (i/2,)          canvas.delete('all')          canvas.create_line(line_reduced, fill='red', width=4, tags='foto1')  

I would need to add it so that this shape can then be reduced or enlarged using two keys. The image would therefore remain the same (shape), it would only be reduced / enlarged.

I will be grateful for any advice.

https://stackoverflow.com/questions/66569356/how-to-enlarge-and-reduce-an-already-drawn-lines-using-certain-buttons March 11, 2021 at 12:54AM

没有评论:

发表评论