I'm not sure if its my computer or what. For some reason when I run programs in class they go through fine but after running the same program at home it doesnt seem to work.
Basically, what I'm trying to do is create an event handler that draws a circle on the canvas each time the mouse is clicked. Also, I added a count to count the clicks and print the number of clicks. I just get an empty canvas. Ofcourse, I don't want anyone to do it for me, but can someone tell me if this program won't run at all because of something I did or the reason I'm not getting anything is because of my computer. Thanks!
class CircleDrawHandler(EventHandler):
def __init__(self):
EventHandler.__init__(self)
self._count = 0
self._mouseClicked = False
def handle(self, event):
if event.getDescription() == 'mouse click':
c = Circle(5, event.getMouseLocation())
event.getTrigger().add(c)
self._mouseClicked = True
elif event.getDescription() == 'mouse release':
if self._mouseClicked:
print('You have made', self._count, 'circle(s)')
if __name__ == '__main__':
paper = Canvas()
handler = CircleDrawHandler()
paper.addHandler(handler)