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

When working with shapes on a Tkinter canvas, you can control the appearance of their outlines by adjusting the thickness and color properties. To change the thickness of a shape's outline, use the width parameter, and use outline to set the border color.

Syntax

The general syntax for creating shapes with custom outline thickness is ?

canvas.create_shape(coordinates, outline='color', width=thickness)

Parameters

  • outline ? Sets the color of the shape's border
  • width ? Sets the thickness of the outline (integer value)
  • coordinates ? Position and size parameters specific to each shape

Example

Here's how to create an oval with a thick green outline ?

# 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 with thick outline
canvas.create_oval(100, 300, 500, 100, outline='green', width=5)

win.mainloop()

Multiple Shapes with Different Outline Thickness

You can create multiple shapes with varying outline thickness ?

from tkinter import *

win = Tk()
win.geometry("700x400")

canvas = Canvas(win, width=650, height=350, bg='white')
canvas.pack()

# Rectangle with thin outline
canvas.create_rectangle(50, 50, 200, 150, outline='blue', width=1)

# Rectangle with medium outline
canvas.create_rectangle(250, 50, 400, 150, outline='red', width=3)

# Rectangle with thick outline
canvas.create_rectangle(450, 50, 600, 150, outline='purple', width=8)

# Oval with very thick outline
canvas.create_oval(150, 200, 450, 320, outline='orange', width=10)

win.mainloop()

Common Use Cases

Width Value Appearance Best For
1-2 Thin outline Subtle borders, detailed drawings
3-5 Medium outline Standard shapes, emphasis
6-10 Thick outline Bold designs, highlighting
10+ Very thick outline Special effects, artistic designs

Output

Running the first example will display a window containing an oval with a thick green outline.

Oval with width=5, outline='green'

Conclusion

Use the width parameter to control outline thickness and outline to set the border color. Higher width values create thicker borders, making shapes more prominent and visually appealing.

Updated on: 2026-03-25T20:46:22+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements