-
Notifications
You must be signed in to change notification settings - Fork 1
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) -> intCreate 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.
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()
Copyright (C) 2020 Luke Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the conditions at https://github.com/Luke-zhang-04/CanvasPlus/blob/master/LICENSE.