I'm using cs1graphics module. I'm like really stuck as to what do next. What I'm attempting to do is create a handler that counts the number of clicks on the canvas and when the exit button is clicked it exits the canvas. I originally added the exit canvas outside of the class before I realized that my class had no attribute to the exit button so I added the exit button in the class but it doesnt come out, nor does my program count the clicks. I've read countlessly on the topic of event handling and I am seriously just stuck. I really don't need anyone to do it for me, I just need to understand what it is that I'm doing wrong. Its driving me crazy!

from cs1graphics import*
class MouseHandler(EventHandler):
    def __init__ (self, textObj):
        self._text = textObj
        self._count = 0

    def handle(self, event):
        if event.getDescription() == 'mouse click':
            self._counter >= 1

class ExitButtonHandler(EventHandler):
    def __init__(self, message='', centerPt=None):
        self._exitButton=Rectangle(60, 30)

    def handle(self, event):

        if event.getDescription() == 'mouse click':
            if event.getTrigger()in self._exitButton:

def main():
    paper=Canvas(700, 600, 'white', 'Number of clicks')

    text1=Text('Times clicked:', 12, Point(140, 550))

    text2=Text('', 12, Point(300, 550))

    exitEvent = ExitButtonHandler()


Recommended Answers

cs1graphics is not a standard library module.

Jump to Post

All 4 Replies

cs1graphics is not a standard library module.

Standard, no, but it is freely available and appears to be reasonably well documented. Unfortunately, I'm short on time right now, or else I would dig into it a bit deeper; as it is, I'll try to get back to it later tonight, if I have the opportunity (though I doubt I will).

unfortunately I was required to used cs1graphics. I have been taking off and putting on for days with no avail!

The reason your instructor is using cs1graphics module is so that outside people can not help you as easily as with common Tkinter GUI toolkit. Most likely your module is limited wrapper of Tkinter.

A number of these Tkinter wrappers have appeared over the years, usually from folks that want to sell you their book. These books are then used by somewhat myopic instructors that are too lazy to teach the full Tkinter code.

Be a part of the DaniWeb community

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