StencilWidget

New in version 1.0.0.

Base class for controlling the stencil instructions of the widget.

Note

See Stencil instructions for more information.

Kivy

from kivy.lang import Builder
from kivy.app import App

KV = '''
Carousel:

    Button:
        size_hint: .9, .8
        pos_hint: {"center_x": .5, "center_y": .5}

        canvas.before:
            StencilPush
            RoundedRectangle:
                pos: root.pos
                size: root.size
            StencilUse
        canvas.after:
            StencilUnUse
            RoundedRectangle:
                pos: root.pos
                size: root.size
            StencilPop
'''


class Test(App):
    def build(self):
        return Builder.load_string(KV)


Test().run()

KivyMD

from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.templates import StencilWidget
from kivymd.utils.fitimage import FitImage

KV = '''
MDCarousel:

    StencilImage:
        size_hint: .9, .8
        pos_hint: {"center_x": .5, "center_y": .5}
        source: "image.png"
'''


class StencilImage(FitImage, StencilWidget):
    pass


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)


Test().run()

API - kivymd.uix.templates.stencilwidget.stencilwidget

class kivymd.uix.templates.stencilwidget.stencilwidget.StencilWidget

Base class for controlling the stencil instructions of the widget

radius

Canvas radius.

New in version 1.0.0.

# Top left corner slice.
MDWidget:
    radius: [25, 0, 0, 0]

radius is an VariableListProperty and defaults to [0, 0, 0, 0].