I've drawn a line in tkinter.Canvas
and now I want to move one end. Is this possible, e.g. with itemconfig
?
import tkinter
tk = tkinter.Tk()
canvas = tkinter.Canvas(tk)
canvas.pack()
line = canvas.create_line(0, 0, 100, 100)
tk.mainloop()
Now I want to change the end of the line to 75, 25
. Is there a better way as to delete the line and create a new one?
Once you've created some item on canvas you can use the following methods to edit the item:
For example:
from tkinter import *
root = Tk()
w = Canvas(root, width=200, height=200)
w.pack()
var = w.create_line(0, 0, 100, 100)
w.coords(var, 0, 0, 75, 25)
root.mainloop()
For learning more about Canvas, you may refer: