CS 115 Summer 2017,

Lab 7 :

Due in Thursday 7/20/17 in Lab

Educational goals of this lab - verify that every student can do the following:

  • Verify that student understand and can use the concepts of: Graphics library



    Overview:

    The package graphics.py is a simple object oriented graphics library designed to make it very easy for novice programmers to experiment with computer graphics in an object oriented fashion. It was written by John Zelle. The most recent version of the library can obtained at http://mcsp.wartburg.edu/zelle/python. This document is a reference to the functionality provided in the library.





  • Make a Simple Math operations using GUI We will start by using the example program for addition operation for two input numbers that are entered by the user as shown in the figure below. To download the graphics library file click here.
    We need to improve the above program in term of the design by adding different colors, shapes, and titles. Also we need to add more opeation beside the addition(subtraion, division, ..etc) .The new program creats a graphical window with the title lab 7 and width 500 and heigt 500. Then it set the background color of the window to white. After that it shows a text "Welcome to Lab 7" centered at point (250,15). Make the text with size 14 and color red. Then draw a line between the points (10,30).
    Then display 2 Text objects(with size 14 and color red) and 2 Entry objects (with size 12 and color blue). The first Text incldues the text "Enter number 1" and it located at location (150,100) with size 14 and color red. The first entry is located at point (250,100) and with 4 places. The second Text box and Entry are located within 25 pixels vertically from the prevoius text and entry.
    Then you program suppose to read the values and add them, subtract the second one from the first one, multiple them and divide the second one by the first one. Finally, you need to display 12 circles filled with the color green. The first circle is located at center (30,250) with radius 20. The other circles are far from each other 40 horizantlly. Then displays 4 Text objects (with size 15 and color green). Each text shows a proper message (e.g The first text includes "The addition result is XX", where XX represents the first number ....etc). The first text is centered at point (200,300), the other texts are far 20 vertically from the prevoius one. All the details above can be seen in the follwoing figure.
  • Program Prolog For every of the the problem above, provide your solution in a file with the comment and prolog provided explaining your information and the program details: # supply program prolog # Prolog # Author: Mary Smith # Email: Mary.Smith@uky.edu # Section: 00 # Date: 8/31/16 ''' Purpose: .... Preconditions: .... Postconditions: .... '''
  • Requirments:
    1- You have to build four different functions (add(), subtract(), multiply(), divide()) also you need to have the main function that will have the Menu and the other things.
    2- Choose names for your variables that make sense, do not use short names consist of one letter. Use good, multi-character, meaningful identifiers (variables) names.
    2- Your output should match the run examples provided with the problems above.
    3- Document your work by putting comments at the top of your program, remember that comments in python are either: starts with # in case the comment is one line only or ''' and ''' if the comment is taking more than one line.
    4- At the top of your program, you should have a prolog (name, date, etc.)
    5- Save the solution for this lab in a file (GUI_.py).
  • When you are done with the lab, show your file to the instructor, sign the lab sheet, and then submit your solution on CANVAS under lab7.