TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Python Tkinter Canvas

Python Tkinter Canvas with python tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, basics, data types, operators, etc.

<< Back to PYTHON

Python Tkinter Canvas

The canvas widget is used to add the structured graphics to the python application. It is used to draw the graph and plots to the python application. The syntax to use the canvas is given below.

Syntax

w = canvas(parent, options)

A list of possible options is given below.

SN Option Description
1 bd The represents the border width. The default width is 2.
2 bg It represents the background color of the canvas.
3 confine It is set to make the canvas unscrollable outside the scroll region.
4 cursor The cursor is used as the arrow, circle, dot, etc. on the canvas.
5 height It represents the size of the canvas in the vertical direction.
6 highlightcolor It represents the highlight color when the widget is focused.
7 relief It represents the type of the border. The possible values are SUNKEN, RAISED, GROOVE, and RIDGE.
8 scrollregion It represents the coordinates specified as the tuple containing the area of the canvas.
9 width It represents the width of the canvas.
10 xscrollincrement If it is set to a positive value. The canvas is placed only to the multiple of this value.
11 xscrollcommand If the canvas is scrollable, this attribute should be the .set() method of the horizontal scrollbar.
12 yscrollincrement Works like xscrollincrement, but governs vertical movement.
13 yscrollcommand If the canvas is scrollable, this attribute should be the .set() method of the vertical scrollbar.

Example

from tkinter import * 

top = Tk()

top.geometry("200x200")

#creating a simple canvas
c = Canvas(top,bg = "pink",height = "200")


c.pack()

top.mainloop()

Output:

Python Tkinter Canvas

Example: Creating an arc

from tkinter import * 

top = Tk()

top.geometry("200x200")

#creating a simple canvas
c = Canvas(top,bg = "pink",height = "200",width = 200)

arc = c.create_arc((5,10,150,200),start = 0,extent = 150, fill= "white")

c.pack()

top.mainloop()

Output:

Python Tkinter Canvas



Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf