-
Notifications
You must be signed in to change notification settings - Fork 17
/
Canvas.py
70 lines (62 loc) · 2.51 KB
/
Canvas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from tkinter import *
def doc():
"""
Using the Tkinter canvas :
• bd : Border Width in pixels. Default value : 2
• bg : Background Colour.
• Confine : If true, the canvas cannot be scrolled outside the scroll region.
• Cursor : The cursor is used in the canvas like an arrow, circle or a dot.
• Height : Used to set the size of the canvas in the Y-dimension.
• Highlightcolor : Changes the highlight colour.
• Relief : Type of border - Raised, ridge, groove, sharpened.
• Scrollregion : It is a tuple that defines over how large in area the canvas can be scrolled.
It takes values in the west,north,east and south(Exact order).
• Width : Used to set the size of the canvas in the X-dimension.
• xscrollincrement : If set in +ve number, then canvas can only be placed in multiples of that number.
• xscrollcommand : Canvas scrolling in the horizontal direction.
• yscrollincrement : Similar to the xscrollincrement
• yscrollcommand : Similar to the xscrollcommand but in vertical direction.
Some Standards :
• Arc
• Image
• Line
• Oval
• Polygon
"""
print(doc.__doc__)
root = Tk()
root.title("Arc")
root.geometry("500x500")
root.iconbitmap("assets/favicon.ico")
y = Canvas(root, width=500, height=500, bg="black")
y.pack()
coordinates = 10, 50, 240, 210
arc = y.create_arc(coordinates, start=0, extent=150, fill="white")
mainloop()
root = Tk()
root.title("Triangle")
root.geometry("500x500")
root.iconbitmap("assets/favicon.ico")
x = Canvas(root, width=500, height=500, bg="red")
x.pack()
coordinates = [0, 0, 200, 100, 0, 200]
poly = x.create_polygon(coordinates, outline="green", fill="yellow", width=3)
mainloop()
root = Tk()
root.title("Images")
root.geometry("500x500")
root.iconbitmap("assets/favicon.ico")
z = Canvas(root, width=500, height=500)
z.pack()
photo = PhotoImage(file="assets/Random.PNG")
a = z.create_image(250, 250, image=photo)
mainloop()
root = Tk()
root.title("Star")
root.geometry("500x500")
root.iconbitmap("assets/favicon.ico")
z = Canvas(root, width=500, height=500, bg="black")
z.pack()
coordinates = [100, 140, 110, 110, 140, 100, 110, 90, 100, 60, 90, 90, 60, 100, 90, 110]
z.create_polygon(coordinates, outline="gold", fill="white", width=3)
mainloop()