Logo Search packages:      
Sourcecode: python-gtkglext1 version File versions  Download package

def scribbling-worms::ScribblingWorm::run (   self )
Overrides the run method of the
Thread base class. This is the starting
point of the ScribblingWorm thread.

You can provide a value for the number
of times to iterate and draw scribbles.
A useful default value is provided.

Definition at line 101 of file scribbling-worms.py.

                  :
        ''' Overrides the run method of the
        Thread base class. This is the starting
        point of the ScribblingWorm thread.

        You can provide a value for the number
        of times to iterate and draw scribbles.
        A useful default value is provided.
        '''

        # Go through a default number of iterations
        # scribbling on the screen. Exit at an intermediate
        # point if the user signals to do so by closing the
        # main window.
        for i in range(0, self.iterations):
            # Randomly generate the next scribble point
            self.x += randint(-2,2)
            self.y += randint(-2,2)

            if self.continue_event.isSet():
                # Scribble one point. Notice we use the
                # locks from PyGtk to serialise access to 2
                # things here, firstly PyGtk itself and secondly
                # the instance of Scribble we're using. Since Scribble
                # is sitting inside the main GUI thread, this way
                # of protecting access to it is safe.
                gtk.threads_enter()
                self.glscene.queue_brush_stroke_draw(self.x, self.y, self.scribble_thick)
                gtk.threads_leave()

                time.sleep(self.sleep_time)
            else:
                # Here we return since the main GUI thread
                # has been terminated.
                return 0

        # Natural death for this thread since we've finished
        # the default number of iterations.
        return 0



Generated by  Doxygen 1.6.0   Back to index