Canvas Basic

This is almost cheating, Canvas is so big and powerful it would take 100 demos to do it justice.  One day maybe we will get back to a fuller treatment of Canvas but for now what you see is what you get.

#TEST AREA   Basic Canvas
#standard set up header code 2 
from tkinter import *
root = Tk()
root.attributes('-fullscreen', True)
root.configure(background='SteelBlue4')
scrW = root.winfo_screenwidth()
scrH = root.winfo_screenheight()  
workwindow = str(1024) + "x" + str(768)+ "+" +str(int((scrW-1024)/2)) + "+" +str(int((scrH-768)/2))
top1 = Toplevel(root, bg="light blue")
top1.geometry(workwindow)
top1.title("Top 1 - Workwindow")
top1.attributes("-topmost", 1)  # make sure top1 is on top to start
root.update()                   # but don't leave it locked in place
top1.attributes("-topmost", 0)  # in case you use lower or lift
#exit button - note: uses grid
b3=Button(root, text="Egress", command=root.destroy)
b3.grid(row=0,column=0,ipadx=10, ipady=10, pady=5, padx=5, sticky = W+N)
#____________________________
lf1=LabelFrame( top1, width=20, height=20, bg="light blue")
lf1.grid(row=0, column=0)

w = Canvas(top1, width=960, height=700, bg="beige")
w.grid(row=1,column=1)

font1="Verdana 12"

w.create_line(0, 0, 200, 100)
w.create_line(0, 100, 200, 0, fill="red", dash=(4, 4))
w.create_rectangle(50, 25, 150, 75, fill="blue")
mytext="'Traditional' Effbot example\n of lines and rectangle"
tl1=w.create_text(250, 20, fill='blue', text=mytext, anchor=NW, activefill="black", font=font1)

myoval= w.create_oval(210, 110, 410, 210, fill="orchid3")
tl2=w.create_text(420, 110, fill='blue', text="Standard Oval", anchor=NW, activefill="black", font=font1 )

mypoly=w.create_polygon(420, 220, 520, 220, 570, 270, 470, 320, 370, 270, fill="yellow", outline="black", width=10)
tl3=w.create_text(580, 220, fill='blue', text="Polygon", anchor=NW, activefill="black", font=font1 )

myarc = w.create_arc(470, 330, 670, 530, fill="red", outline="black", width="5")
tl4=w.create_text(650, 270, fill='blue', text="Arc examples", anchor=NW, activefill="black",font=font1 )

myarc2 = w.create_arc(650, 330, 750, 530, fill="red", outline="black", width="10", style=ARC)

myarc3 = w.create_arc(700, 330, 900, 530, fill="red", outline="black", width="5", style=CHORD)

arctxt="PIESLICE (default)   ARC        CHORD"
tl5=w.create_text(530, 450, fill='blue', text=arctxt, anchor=NW, activefill="black",font=font1 )

btmapid=w.create_bitmap(650, 50, bitmap='question', background='LightGoldenrod2', foreground='green')
tl6=w.create_text(650, 70, fill='blue', text="Bitmap example", anchor=NW, activefill="black", font=font1 )

b1=Button(w, width=20, height=20, text="test", bg='linen', fg='green', font="Verdana 14 bold", bd=10)
window1=w.create_window(50,330, width=200, height=100, anchor=N+W, window=b1)
#____________________________
root.mainloop()