# Joe Schmoe
#
# Program:     nameGraphics.py
# Description: Display a person's name with a rectangle drawn around it.
# Input:       A person's name and a mouse location
# Output:      The person's name placed at the mouse click location with a rectangle
#              drawn around it.

from graphics import *

def main ():
    name = input ("Enter a name: ")

    win = GraphWin("What's my name?", 400,400)
    win.setBackground ("white")

    # draw the name
    position = win.getMouse()
    message = Text (position, name)
    message.setFill ("blue")
    message.draw (win)

    # draw the rectangle
    # the scaling factors of 10 and 5 depend on the font
    hOffset = len(name) / 2 * 10
    vOffset = len(name) / 2 * 5
    rect = Rectangle (Point (position.x-hOffset, position.y-vOffset), Point (position.x+hOffset, position.y+vOffset))
    rect.draw (win)

    # pause the window
    message = Text (Point (200, 390), "Click to close")
    message.setFill ("black")
    message.draw (win)

    win.getMouse()
    win.close()
main()
