How to change the thickness of a shape's outline on a Tkinter canvas?

TkinterPythonGUI-Programming

Let us suppose we have created an oval on a Tkinter canvas. The task is to change the thickness of the oval's outline. To change the thickness of the outline, provide a border or outline to a rectangle, define the width property in the constructor and assign it an integer value. You can also define the outline property to set a color to the outline of the oval.

Example

#Import the required libraries
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry
win.geometry("700x350")

# Define a Canvas Widget
canvas = Canvas(win, width=500, height=350)
canvas.pack()

# Create an oval in Canvas
canvas.create_oval(100,300,500,100, outline='green', width=5)

win.mainloop()

Output

Running the above code will display a window containing an oval with a thick green outline.

raja
Published on 26-May-2021 11:48:46
Advertisements