November 28th, 2012, 09:07 AM
Python While loop
hey! So i have a python graphics program and im stuck and how to do the next part.
• Write a graphics program that simulates a calculator.
• The window that the user sees must have a label and an area for the first operand, the second operand, and the result.
• The default values for the two operands need to be 0.
• The user needs to be able to choose whether to add, subtract, multiply, and divide the operands to produce the result by clicking on the appropriate button. The operation will only occur when the user clicks in the box labeled with that operation.
• The result will be updated as long as the user continues to choose an operation.
• The result will be displayed to two decimal point accuracy.
I already have this much..
from graphics import *
#Create graphics window
win = GraphWin("Mathemathics", 400, 400)
#Make the background grey
win.setCoords(0, 0, 90, 100)
r1 = Rectangle(Point(5,5), Point(20,20))
r2 = r1.clone()
r3 = r1.clone()
r4 = r1.clone()
Text(Point(15,80), "First Number:").draw(win)
e1 = Entry(Point(20,75), 8)
Text(Point(15,60), "Second Number:").draw(win)
e2 = Entry(Point(20,55), 8)
If anyone could help me out I would greatly appreciate it.