- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to colorize the outline of a Tkinter canvas rectangle?
We can create different shapes such as rectangles, arcs, circles, etc., on a Tkinter canvas. Canvas widget has many inbuilt functions and methods which can be used to configure the property of the shapes.
To colorize the outline of a canvas rectangle, we have to specify the color value in the outline property. It applies to the function create_rectangle(top, left, bottom, right) where the outline should be visible.
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x350") #Create a canvas object canvas= Canvas(win, width= 300, height= 350) #Create a rectangle in canvas canvas.create_rectangle(300,200,10,10, outline= "red", fill= "white") canvas.pack() win.mainloop()
Running the above code will display a rectangle inside the canvas widget.
Observe that we have set the outline of the rectangle as Red.
- How to colorize the outline of a canvas rectangle in Tkinter?
- How to make a Tkinter canvas rectangle transparent?
- Tkinter - How to put an outline on a canvas text
- How to change the thickness of a shape's outline on a Tkinter canvas?
- How to put an outline on a canvas text on Tkinter?
- How to draw a rectangle on HTML5 Canvas?
- How to change the color of a Tkinter rectangle on clicking?
- How to remove the outline of an oval in Tkinter?
- How to draw a rounded Rectangle on HTML Canvas?
- How to change the background color of a tkinter Canvas dynamically?
- How to clear Tkinter Canvas?
- How to set the font size of a Tkinter Canvas text item?
- How to get the coordinates of an object in a Tkinter canvas?
- How to make a Button using the Tkinter Canvas widget?
- Changing the color a Tkinter rectangle on clicking