Can anyone please help me figure out what I am NOT doing to make this program
work properly.....PLEASE !!
I need to be able to take the user input that is entered in the two graphical
boxes of the first window and evaluate it to generate a graph chart which is
suppose to display in the second window. I am totally at a loss for what I am
NOT doing, and I know it is something so simple that I am overlooking because I
am making this harder that what it most likely really is.
But I just cannot get it to work properly. Please HELP !!! Help me
understand what I am doing wrong and how to fix it. I believe I am on the
right path but I'm becoming frustrated and discouraged.
I have attached a copy of the code I've compiled so far.
# futval_graph2.py
from graphics import *
def main():
# Introduction
print("This program plots the growth of a 10-year investment.")
win = GraphWin("Growth of 10-Year Investment", 400, 300)
win.setCoords(0.0, 0.0, 3.0, 4.0)
# Draw the interface
Text(Point(1,3), " Enter principal:").draw(win)
input = Entry(Point(2,3), 5)
input.setText("0.00")
input.draw(win)
principal = eval(input.getText())
Text(Point(1.10,2.5), " Input APR:").draw(win)
input2 = Entry(Point(2,2.5), 5)
input2.setText("0.0")
input2.draw(win)
apr = eval(input2.getText())
output = Text(Point(0,0),"")
output.draw(win)
button = Text(Point(1.5 ,1.65),"Graph It")
button.draw(win)
Rectangle(Point(.5,2), Point(2.5,1.25)).draw(win)
# wait for a mouse click
win.getMouse()
win = GraphWin("Investment Growth Chart", 320, 240)
win.setBackground("white")
win.setCoords(-1.75,-200, 11.5, 10400)
# Create a graphics window with labels on left edge
Text(Point(-1, 0), ' 0.0K').draw(win)
Text(Point(-1, 2000), ' 2.5K').draw(win)
Text(Point(-1, 5000), ' 5.0K').draw(win)
Text(Point(-1, 7500), ' 7.5k').draw(win)
Text(Point(-1, 10000), '10.0K').draw(win)
# Draw bar for initial principal
bar = Rectangle(Point(0, 0), Point(1, principal + apr))
bar.setFill("green")
bar.setWidth(2)
bar.draw(win)
# Draw a bar for each subsequent year
for year in range(1, 11):
bar = Rectangle(Point(year, 0), Point(year+1, principal))
bar.setFill("green")
bar.setWidth(2)
bar.draw(win)
win.getMouse()
win.close()
main()
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor