def draw_roundedrect(self, x, y, w, h, r=10):
        """Draws a rounded rectangle"""
        # A****BQ
        # H     C
        # *     *
        # G     D
        # F****E

        context = self.context

        context.save

        context.move_to(x+r, y)  # Move to A
        context.line_to(x+w-r, y)  # Straight line to B
        context.curve_to(x+w, y, x+w, y, x+w, y+r)  # Curve to C
        # Control points are both at Q
        context.line_to(x+w, y+h-r)  # Move to D
        context.curve_to(x+w, y+h, x+w, y+h, x+w-r, y+h)  # Curve to E
        context.line_to(x+r, y+h)  # Line to F
        context.curve_to(x, y+h, x, y+h, x, y+h-r)  # Curve to G
        context.line_to(x, y+r)  # Line to H
        context.curve_to(x, y, x, y, x+r, y)  # Curve to A

        context.restore
def draw_roundedrect ( self , x , y , w , h , r = 10 ) : context = self . context context . save context . move_to ( x + r , y ) context . line_to ( x + w - r , y ) context . curve_to ( x + w , y , x + w , y , x + w , y + r ) context . line_to ( x + w , y + h - r ) context . curve_to ( x + w , y + h , x + w , y + h , x + w - r , y + h ) context . line_to ( x + r , y + h ) context . curve_to ( x , y + h , x , y + h , x , y + h - r ) context . line_to ( x , y + r ) context . curve_to ( x , y , x , y , x + r , y ) context . restore
Draws a rounded rectangle