Question
Gui3.py code: http://facweb.northseattle.edu/cl_djinguji/csc110-m17/code/Gui3.py Second post havent recieved any assistance. Need assistance on this assignment creating a Python script in version 3.6: Learning Activity: Parameterized Gui
Gui3.py code:
http://facweb.northseattle.edu/cl_djinguji/csc110-m17/code/Gui3.py
Second post havent recieved any assistance. Need assistance on this assignment creating a Python script in version 3.6:
Learning Activity: Parameterized Gui
In this lab, you will gain some additional experience working with the Gui module and working with user input. For the plus version, this is also an opportunity to work with some lists.
Download the starting point code, paramGui.py. Here is a copy of the code:
import Gui3 def main(): win = Gui3.Gui() size = 100 canvas = win.ca(2*size + 50, 2*size + 50) canvas.circle([0,0], size ) canvas.rectangle([[-size, -size], [size, size]] ) canvas.polygon([[-size, 0], [0, size], [size, 0], [0, -size]], outline='black' ) win.mainloop() main()
Before you run it, see if you can figure out what kind of output window it will make.
As you figure out what's going on in this file, make sure that you document it with comments.
Minus Version
For the minus version, you will add some color to the graphic and let the user specify several characteristics for the window.
Let's start by adding some color to the circle. To fill in the circle, add the named argument, fill='green', to the canvas.circle call. This value should be added at the end of the argument list.
canvas.circle([0,0], size, fill='green')
Run it to verify that the image has changed.
Now make the fill of the center diamond white.
Finally, fill the outer square yellow. This is require you to make some other changes to the code. The image should look like this.
1) What change needs to be made to the code, other than just adding the fill argument?
2) Why is this necessary?
Write the answers to these two questions in a separate text file, lab12.txt, that you shall submit as part of this lab.
Before the call to win.mainloop(), update the script to ask the user for a title for the window. Use the title method of the window object to change the title.
For the next part of the lab, ask the user to specify the size of the outer square. Use the input built-in function. You will need to make sure that the value is an int for it to be used by the Gui routines. You can simply cast it to int. If the user enters 200 for the size, the window should look like it does "right now". That is, the size of the outer square is 200x200 in the code you downloaded.
Here's what is looks like with size 100, 300.
Sample run
Here is an example of the user interaction for the minus version.
Enter a title: minus version Enter the size for the square: 300
Notice that the title is the first question and the size is the second question.
This will produce this output window.
Check Version
For the check version, update the query so that the outer square could be rectangular. That is, ask for both a height and a width for outer rectangle.
Enter a title: check version Width for the rectangle: 300 Height for the rectangle: 150
Once again, notice that the title is the first question, then the two dimensions for the window.
Here's what the output window should look like.
Plus Version
For the plus version, you get to do something a bit creative, after a fashion. You will also get to exercise your trigonometry. (For those of you who haven't had trig yet, not to worry. I'll be giving you all of the equations that you'll need.)
For the plus, in addition to what is needed for the minus and the check, the script will create a second window. For that second window, the user will specify the number of corners for the inner polygon. This second window will be the same size as the original downloaded code. The canvas will be 250x250. The external shape will be a square with side 200, and the enclosed curve will be a circle of diameter 200.
If the user requests four (4) corners, it will look like the minus version. If they request three (3) corners, there will be a triangle inscribed within the circle. If five (5), a pentagon; etc. For a special challenge, try to make the code form a "star" when the number of corners is greater than 4; eg.five, seven, eight. You actually will have to do some special handling for six, ten, ... 4N+2. (In this case, you need to superimpose two stars with 2N+1 points, one pointing up and one pointing down. Here is an example for six, two triangles. Of course, you could avoid these cases by making regular polygons, like this hexagon.) Also, if the user enters a. number which is less than 3, just default back to 4.
How do we do these magic calculations? Polar coordinates.
Sample run
Here is an example of the user interaction for the plus version.
Enter a title: check version Width for the rectangle: 300 Height for the rectangle: 150 Enter a title: plus version Enter the number of points: 5
Notice that the two questions for the plus window follow the check version.
This will produce output windows: first and second.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started