Skip to content

create_arrow()

Luke edited this page Apr 12, 2020 · 4 revisions

CanvasPlus.create_arrow()

Creating arrows in Tkinter canvas is cumbersome and annoying. This method lets you specify the point of the arrow and it's dimensions rather than all the points.

from numbers import Real
def create_arrow(self, x1: Real, y1: Real, headLength: Real, headWidth: Real, bodyLength: Real, bodyWidth: Real, **kwargs) -> int

Create arrow with x1, y1 as the tip; headWith, headLengh as the length and width of the arrowhead; and bodyLength, bodyWidth as the length and width of the arrow body.

Example:

from tkinter import Tk
from CanvasPlus import CanvasPlus
root = Tk()

canvas = CanvasPlus(root, width=800, height=800, background = "white")
canvas.pack()

canvas.create_arrow(600, 600, 50, 50, 150, 20, fill = "grey", outline = "black")
canvas.create_arrow(100, 100, 10, 10, 200, 5, fill="green", outline="#39f7a2", width=5)
canvas.create_arrow(300, 300, 100, 100, 400, 50, fill="red", outline="gold", width=3)

canvas.update()
canvas.mainloop()

Screen Shot 2020-03-30 at 2 29 48 PM

Clone this wiki locally