I'm supposed to create a menu that will give the user options to open and close a file called shapes.txt that opens a file of a bunch of shapes drawn using graphics.py. This is the example we're given but im not sure what to do. When the user types in the name of the shapes file its supposed to open up a window with all of the shapes i've drawn in shapes.txt.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I'm supposed to create a menu that will give the user options to open and close a file called shapes.txt that opens a file of a bunch of shapes drawn using graphics.py. This is the example we're given but im not sure what to do. When the user types in the name of the shapes file its supposed to open up a window with all of the shapes i've drawn in shapes.txt.

from graphics import *
import os
import sys

WINDOW_WIDTH=600
WINDOW_HEIGHT=600

def main ():
    # in document, specify the default width and height
    win = GraphWin("", WINDOW_WIDTH, WINDOW_HEIGHT)
    win.setCoords(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)  # bigger than GraphWin size = zoom out, smaller = zoom in

    # ask user for the name of the shapes file
    # this is where you would read the shapes file and store the information
    # i recommend storing the shape properties in a dictionary
    # i recommend storing the shapes in a list

    # this is where you would draw the shapes
    # i recommend creating a separate function to draw each shape

    # drawing a circle
    s = Circle(Point(100,100), 100)   # Point is created with x,y position for center of circle, then the radius
    s.setFill("red")
    s.draw(win)

    # now a rectangle
    s = Rectangle(Point(200,200), Point(300,300))
    s.setFill("blue")
    s.draw(win)

    # pause the program so the graphics window will stay visible
    input ("Hit return key to exit the program")
    win.close()


# this insures that if you run the program from the command line, it will call the
# main function, e.g.
# python graphics_example.py
if __name__ == "__main__" :
    main()

Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY