201k views
5 votes
Given the following code, what are the dimensions, in pixels, of the shape created? import tkinter class myShape: def __init__(self): self.main_window = tkinter.Tk() self.canvas = tkinter.Canvas(self.main_window, width=200, height=200) self.canvas.create_rectangle(30,30, 175, 175) self.canvas.pack() tkinter.mainloop() shape = myShape()

User Nereyda
by
8.5k points

1 Answer

3 votes

Answer:

Width: 145 px, Height: 145 px

Step-by-step explanation:

To build a figure in Python with canvas, remember that drawing a rectangle is represented with self.canvas.create_rectangle(x1,y1,x2,y2), where x1,y1 are the coordinates of the top left corner of the figure, and x2,y2, the coordinates of the bottom right corner.

Based on your data, the shape formed will not be a rectangle, but a square. The measures in x2, y2 are equal, so a square figure will form. For example, if you had (30,30,175,150) this would create a rectangle figure.

User Jorge Ramos
by
8.8k points