What are your kids’ names?

Prasad is 4 and Ravi is 18 months. As a parent, I am contractually obligated to show you a photo of my kids any time they are mentioned. Kids

What’s your dog’s name?

Oberon. He has half jack russel Terrier, half pug, all crazy.

Why did you draw mini stack diagrams to explain the shapes in the graphics window?

They are objects, and therefore go on the execution stack of a program. Using the stack diagrams helps us visualize how the program keeps track of information and passes it around when needed. We’ll use the stack diagram for every module going forward.

How can we draw a circle without a black border?

Try using the setOutline() method. I don’t think there is a “no color” option, but you can have it match by using the same color as setFill().

Can you the user dictate what colors the shapes are?

The colorPicker module is one choice. You could use the terminal to ask them to enter a color. Or you could use the graphics window with instructions on where to click to choose a color and use getMouse() to detect where they picked.

For example, you can put a Text in the upper-right hand corner saying “Click here for Red”. If the user click’s near that box, set the color to red.

How can I control layering of objects?

Great question. Python draws everything from back to front. So the order in which you call the draw() methods matters. For example, if you create and draw a square, then create and draw a circle in the same spot, the circle will always be on top.

How to animate objects

We’ll do this first thing on Friday.

How do I get an object to be randomly generated at any location

import random
win = GraphWin(...) # create a window as you see fit

width = win.getWidth()
height = win.getHeight()

randx = random.randrange(width)
randy = random.randrange(height)

randPoint = Point(randx, randy)
randCircle = Circle(randPoint, 20)
randCircle.draw(win)

That should create a randomly placed circle of radius 20 somewhere in your window

If you want to draw a lot of shapes, is there a more compact way to making all those shapes?

Loops and functions!

Can you make the fill a gradient

I don’t believe so. It’s not the most full-featured of libraries.

What are other examples of setters?

setFill(), move, setOutline are just a few from the graphics library.
For lists, you can remove an element using either pop() or remove().

I am still confused about OOP and methods/objects.

We just got started, so this is expected. Come and see me in office hours or if my door is open and I’d be happy to go over more details/examples.

I’m still a little confused about what defines an object versus a variable?

For our purposes, all objects are assigned to a variable. E.g., we create a GraphWin object and call it win. Objects are a value and variables are how we store those values. So, just as we create an integer variable x = 5 who has a value 5 and variable name x, we create a GraphWin object and give a variable name win.