##########################################################################################
# Create a Tkinter screen with both a Canvas and a Frame
##########################################################################################
from tkinter import *			                #import entire tkinter framework
from tkinter import messagebox                  #import popup dialogs 

#### Create a window with a Canvas and a Frame ###########################################

win = Tk( )					                    #call Tk( ) constructor to create a root window
win.title("Tkinter Window with Canvas")	        #set a window title
win.geometry("400x500")                         #window size

### The Canvas Portion ###################################################################

canvas = Canvas(win, width=400,height=400)

canvas.create_rectangle(10,10,100,100,fill='red')                       #left/top point, right/bottom point     
canvas.create_rectangle(110,10,250,100,fill='blue',outline='red')
canvas.create_oval(260,10,350,100,fill='yellow')                        #left/top point, right/bottom point  
                                                                        #of virtual enclosing square
canvas.create_line(10,10,150,150,50,150,10,10,width=2,fill='black')     #pairs of x,y points

canvas.create_arc(50,150,300,300,start=45,extent=90,fill='green')       #left/top point, right/bottom point           
canvas.create_arc(50,150,300,300,start=135,extent=90,fill='brown')      #of virtual enclosing square    
canvas.create_arc(50,150,300,300,start=225,extent=90,fill='white')      #starting angle, extend degrees    
canvas.create_arc(50,150,300,300,start=315,extent=90,fill='black')      #by defuault, arc will be a pie slice   

canvas.create_polygon(390, 180, 330, 110, 260,180, fill="gray")         #3point polygon = triangle

canvas.create_oval(280,30,290,40)                                                                        
canvas.create_oval(320,30,330,40)
canvas.create_arc(280,30,330,80,start=180,extent=180,style='arc')       #style=arc, do not close the arc


canvas.create_text(150,350,text="It's a Start") 

canvas.pack()                                               #make the canvas visible

### The Frame Portion ####################################################################

frame1 = Frame(win, bg='cyan')

def submitEvent( ):                                                 #method is called upon submit
    name = nameField.get()                                          #get value entered in Entry field
    messagebox.showinfo('Thanks', F"You entered: {name}")           #display a popup dialog

nameLabel    = Label(frame1, text="Enter your favorite shape: ", bg="cyan")    
nameField    = Entry(frame1, width=30)
submitButton = Button(frame1, width=9, text="Submit", cursor='hand2', command=submitEvent)  

nameLabel.grid(   row=0, column=0, pady=6, padx=5, sticky=E)        #place the components in the frame
nameField.grid(   row=0, column=1, pady=6, padx=5, sticky=W)
submitButton.grid(row=1, column=1, padx=5, pady=8, sticky=W)

frame1.pack()                                   #make the frame visible

win.mainloop()                                  #make the window visible