Here is the program 13-16. GUI Programming (draw_square.py) Program 16 1 2 = Thi
ID: 3700888 • Letter: H
Question
Here is the program 13-16.
GUI Programming (draw_square.py) Program 16 1 2 = This program draws a rectangle on a Canvas. import tkinter 4 class MyGUI: def __init_(self): # Create the main window. self.main_window = tkinter.Tk() # Create the Canvas widget. seif.canvas = tkinter. Canvas(self.main window, width=200, height= # Draw a rectangle. self.canvas.create rectangle(20, 20, 180, 180) # Pack the canvas. self.canvas.pack() # Start the mainloop. tkinter.mainloop() 1 # Create an instance of the MyGUI class. 2 my_gui = MyGUI () re 29 Window displayed by Program 16 4 tk - O X There are several optional keyword arguments that you can pass to the create method. Table 3 lists some of the more commonly used ones.Explanation / Answer
'''
VERSON: PYTHON 2.7
'''
from Tkinter import *
root = Tk()
root.title("GUI")
topFrame = Frame(root,bd = 3,relief = GROOVE,background="#E5E3E2")#top frame
bottomFrame = Frame(root,bd = 4,relief = GROOVE,background="#E5E3E2")#bottom frame
#topframe two labels
Label1 = Label(topFrame, text="We Are",fg = "#131310",bg = "#E0DDBE",borderwidth = 3,relief = "ridge")
Label2 = Label(topFrame, text="Penn State",fg = "#131310",bg = "#E0DDBE",borderwidth = 2,relief = "ridge")
#bottomframe two labels
Label3 = Label(bottomFrame, text="We Are",borderwidth = 2,relief = "ridge",fg = "#010506",bg = "#DFDEE7")
Label4 = Label(bottomFrame, text="Penn State",borderwidth = 2,relief = "ridge",fg = "#010506",bg = "#DFDEE7")
#PACKING 4 LABELS
Label1.pack(side=TOP,padx = 5,pady =5)
Label2.pack(side=BOTTOM,padx = 5,pady =5)
Label3.pack(side=LEFT,padx = 5,pady =5)
Label4.pack(side=RIGHT,padx = 5,pady =5)
#PACKING TOP AND BOTTOM FRAMES
topFrame.pack(side=TOP,padx = 120,pady = 100)
bottomFrame.pack(side=BOTTOM,padx = 150,pady = 100)
#MINIMUM SIZE FOR WINDOW
root.minsize(200,200)
#mainloop
root.mainloop()