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):
    self._count = 0
    self._mouseClicked = False
  def handle(self, event):
    if event.getDescription() == 'mouse click':
      c = Circle(5, event.getMouseLocation())
      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()
Re: event handler 80 80

We don't have the inherited class, EventHandler, and don't know what graphics tool kit you are using, so can not offer any assistance other than to say that you don't call the function "handle" anywhere in the code posted that I can see.

Re: event handler 80 80

Sorry, I'm importing cs1graphics. I used the handle function with addHandler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.