Saturday, March 1, 2014

Calculate the Area and Perimeter of any Rectangle



In this program I've learned to adjust the width of a program. The width could be incorporated in 'GraphWin'. Points could also become identified by creating a variable that logs the user to 'getMouse()', and follow through with a 'click'. Following this, we can identify each x and y coordinate by identifying said variable with 'getX()' and 'getY()' respectively.

Entry boxes are a nice way of outputing data. After defining a short algorithm that calculates the area nd perimeter of said 'rectangle', we can output the results graphically use an 'Entry' syntax. When creating an entry the first step would be to create a graphical interface for the entry box. This could be obtained with the syntax: 'Entry([Point(x,y)], [width])'. After setting this, we can place any reasonable text inside. We can do this with the sytax [variable].setText([variable]). I obtained a 'nontype' error when I set.Text in the entry [variable] draw in the window like this:

entry1 = Entry(Point(150, 40, 10)).draw(win)

I fixed this by changing it to the following:

entry1 = Entry(Point(150, 40), 10)
entry1.draw(win) 

set.Text worked in the case above because there was a recognizable variable in which 'entry1' was set. In the case where it would drawn immediately, it was recognized as a 'drawing' feature.




No comments:

Post a Comment