stroke_demo.py
def _handle_mouse_events(self, event):
        """ Use various mouse events to start, trace and finish a stroke path. """
        event_type = event.GetEventType()
        if event_type == wx.EVT_LEFT_DOWN.evtType[0]:
            point_x, point_y = event.GetPosition().Get()
            self.points = [wx.Point(point_x, point_y)]  # Initialize points for drawing.
            self.stroke.start_path(point_x, point_y)  # Initialize stroke path.
            self.Refresh()  # Clear the lines since there's no points to plot.
        if self.stroke.is_stroking:
            if event_type == wx.EVT_MOTION.evtType[0]:
                point_x, point_y = event.GetPosition().Get()
                self.points.append(wx.Point(point_x, point_y))  # Add point to draw lines.
                self.stroke.append_path(point_x, point_y)  # Add the position to the stroke path.
                self.Refresh()  # Update the window with the path lines.
            if event_type in (wx.EVT_LEAVE_WINDOW.evtType[0], wx.EVT_LEFT_UP.evtType[0]):
                stroke_code = self.stroke.decode_path()  # Decode the path and display it.
                stroke_name = stroke_decode.name(stroke_code)
                self.text_ctrl_stroke.SetValue(f"{stroke_code}: {stroke_name}")
                self.Refresh()  # Update the window to add the grid if there is one.
        event.Skip()
 Use various mouse events to start, trace and finish a stroke path. 
Use various mouse events to start, trace and finish a stroke path.
Use various mouse events to start trace and finish a stroke path .
def _handle_mouse_events(self, event):
        event_type = event.GetEventType()
        if event_type == wx.EVT_LEFT_DOWN.evtType[0]:
            point_x, point_y = event.GetPosition().Get()
            self.points = [wx.Point(point_x, point_y)]  
            self.stroke.start_path(point_x, point_y)  
            self.Refresh()  
        if self.stroke.is_stroking:
            if event_type == wx.EVT_MOTION.evtType[0]:
                point_x, point_y = event.GetPosition().Get()
                self.points.append(wx.Point(point_x, point_y))  
                self.stroke.append_path(point_x, point_y)  
                self.Refresh()  
            if event_type in (wx.EVT_LEAVE_WINDOW.evtType[0], wx.EVT_LEFT_UP.evtType[0]):
                stroke_code = self.stroke.decode_path()  
                stroke_name = stroke_decode.name(stroke_code)
                self.text_ctrl_stroke.SetValue(f"{stroke_code}: {stroke_name}")
                self.Refresh()  
        event.Skip()
def _handle_mouse_events ( self , event ) : event_type = event . GetEventType ( ) if event_type == wx . EVT_LEFT_DOWN . evtType [ 0 ] : point_x , point_y = event . GetPosition ( ) . Get ( ) self . points = [ wx . Point ( point_x , point_y ) ] self . stroke . start_path ( point_x , point_y ) self . Refresh ( ) if self . stroke . is_stroking : if event_type == wx . EVT_MOTION . evtType [ 0 ] : point_x , point_y = event . GetPosition ( ) . Get ( ) self . points . append ( wx . Point ( point_x , point_y ) ) self . stroke . append_path ( point_x , point_y ) self . Refresh ( ) if event_type in ( wx . EVT_LEAVE_WINDOW . evtType [ 0 ] , wx . EVT_LEFT_UP . evtType [ 0 ] ) : stroke_code = self . stroke . decode_path ( ) stroke_name = stroke_decode . name ( stroke_code ) self . text_ctrl_stroke . SetValue ( f"{stroke_code}: {stroke_name}" ) self . Refresh ( ) event . Skip ( )
Use various mouse events to start, trace and finish a stroke path.
Use various mouse events to start trace and finish a stroke path .
""" Use various mouse events to start, trace and finish a stroke path. """ # Initialize points for drawing. # Initialize stroke path. # Clear the lines since there's no points to plot. # Add point to draw lines. # Add the position to the stroke path. # Update the window with the path lines. # Decode the path and display it. # Update the window to add the grid if there is one.
self
event