Skip to content

create_round_rectangle()

Luke edited this page Apr 12, 2020 · 4 revisions

CanvasPlus.create_round_rectangle()

There's no easy way to create a rectangle with rounded corners. This method makes it easy.

from numbers import Real
def create_round_rectangle(self, x1: Real, y1: Real, x2: Real, y2: Real, radius: Real = 25, **kwargs) -> int

Also, making a rectangle with 4 circles is quite laborious and is something to avoid.

Example:

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

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

canvas.create_round_rectangle(400, 400, 500, 500, radius = 75, fill = "blue", outline = "orange", width = 5)
canvas.create_round_rectangle(100, 250, 300, 410, radius = 25, fill = "#f4f4f4", outline = "black", width = 3)
canvas.create_round_rectangle(500, 600, 700, 800, radius = 10, fill = "red", width = 0)

canvas.update()
canvas.mainloop()

Screen Shot 2020-03-30 at 2 21 58 PM

Clone this wiki locally