February 13th, 2005, 05:29 PM
I have been having trouble trying to clone an object in particular a square. I want the program to produce new squares after a user clicks in the window. Here is what I have so far. Thanks for any help.
from graphics import *
win = GraphWin()
shape = Rectangle(Point(50,50), Point(100,100))
output = Text(Point(100,125), "Click again to quit")
February 14th, 2005, 03:04 AM
There is a copy module which provides functions for cloning objects (see the current python documentation for details).
To clone a square, try this:
new_shape = copy.deepcopy(shape)
February 21st, 2005, 10:55 PM
or, you could do something like this (i think this would work):
but, that may just modify the first one
another way is though the copy module, which sbkwi describes.