Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs.
Note: For more information, refer to Python GUI – tkinter
The Canvas widget lets us display various graphics on the application. It can be used to draw simple shapes to complicated graphs. We can also display various kinds of custom widgets according to our needs.
C = Canvas(root, height, width, bd, bg, ..)
- root = root window.
- height = height of the canvas widget.
- width = width of the canvas widget.
- bg = background colour for canvas.
- bd = border of the canvas window.
- scrollregion (w, n, e, s)tuple defined as a region for scrolling left, top, bottom and right
- highlightcolor colour shown in the focus highlight.
- cursor It can defind as a cursor for the canvas which can be a circle, a do, an arrow etc.
- confine decides if canvas can be accessed outside the scroll region.
- relief type of the border which can be SUNKEN, RAISED, GROOVE and RIDGE.
Some common drawing methods
- Creating an Oval
oval = C.create_oval(x0, y0, x1, y1, options)
- Creating an arc
arc = C.create_arc(20, 50, 190, 240, start=0, extent=110, fill="red")
- Creating a Line
line = C.create_line(x0, y0, x1, y1, ..., xn, yn, options)
- Creating a polygon
oval = C.create_polygon(x0, y0, x1, y1, ...xn, yn, options)
Example 1: Simple Shapes Drawing
Example 2: Simple Paint App
- Python | Menu widget in Tkinter
- Python Tkinter - Checkbutton Widget
- Python Tkinter - Text Widget
- Python | PanedWindow Widget in Tkinter
- Python Tkinter - ListBox Widget
- Python Tkinter - ScrolledText Widget
- Python Tkinter - Scale Widget
- Python Tkinter - Toplevel Widget
- Combobox Widget in tkinter | Python
- Python Tkinter - Frame Widget
- Progressbar widget in Tkinter | Python
- Python Tkinter - Entry Widget
- Python Tkinter - Menubutton Widget
- Python Tkinter - MessageBox Widget
- Creating Tabbed Widget With Python-Tkinter
- Python Tkinter - Validating Entry Widget
- Python Tkinter | Create different shapes using Canvas class
- Python Tkinter | Moving objects using Canvas.move() method
- Python Tkinter | Create different type of lines using Canvas class
- Tkinter - Read only Entry Widget
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.