Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
57 views

COMP Python Tkinter Canvas Nts2

The canvas widget is used to add structured graphics to Python applications. It can draw graphs and plots. The canvas is created using the Canvas function, which takes the parent window and optional configuration options like background color, height, width, and border width as arguments. Common methods on canvas include create_arc to draw arcs, and pack to display the canvas.

Uploaded by

Jer Felysse
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

COMP Python Tkinter Canvas Nts2

The canvas widget is used to add structured graphics to Python applications. It can draw graphs and plots. The canvas is created using the Canvas function, which takes the parent window and optional configuration options like background color, height, width, and border width as arguments. Common methods on canvas include create_arc to draw arcs, and pack to display the canvas.

Uploaded by

Jer Felysse
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer

Python Tkinter Canvas


Sources: Canvas,

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 7. relief
python application. The syntax to use the It represents the type of the border.
canvas is given below. The possible values are SUNKEN, RAISED,
GROOVE, and RIDGE.
SYNTAX
8. scrollregion
1. w = canvas(parent, options)
It represents the coordinates specified
A list of possible options is given below.
as the tuple containing the area of the
1. bd canvas.

The represents the border width. The 9. width


default width is 2.
It represents the width of the canvas.
2. bg
10. xscrollincrement
It represents the background color of
If it is set to a positive value.
the canvas.
The canvas is placed only to the multiple of
3. confine this value.

It is set to make the canvas 11. xscrollcommand


unscrollable outside the scroll region.
If the canvas is scrollable, this attribute
4. cursor should be the .set() method of the horizontal
scrollbar.
The cursor is used as the arrow, circle,
dot, etc. on the canvas. 12. yscrollincrement

5. height Works like xscrollincrement but


governs vertical movement.
It represents the size of the canvas in
the vertical direction. 13. yscrollcommand

6. highlightcolor If the canvas is scrollable, this attribute


should be the .set() method of the vertical
It represents the highlight color when
scrollbar.
the widget is focused.

1
8. c = Canvas(top,bg = "pink",height =
"200",width = 200)
9.
10. arc = c.create_arc((5,10,150,200),start
= 0,extent = 150, fill= "white")
11.
EXAMPLES 12. c.pack()
13.
1. from tkinter import * 14. top.mainloop()
2.
3. top = Tk() Output:
4.
5. top.geometry("200x200")
6.
7. #creating a simple canvas
8. c = Canvas(top,bg = "pink",height =
"200")
9.
10.
11. c.pack()
12.
13. top.mainloop()

Output:

Creating an Arc

1. from tkinter import *


2.
3. top = Tk()
4.
5. top.geometry("200x200")
6.
7. #creating a simple canvas
2

You might also like