Non rectangular StencilView

9 views
Skip to first unread message

Tim Sheerman-Chase

unread,
Jul 22, 2016, 4:15:24 PM7/22/16
to Kivy users support

I want to used something like a non-rectangular StencilView, so that widgets are clipped within a custom shape. I notices the canvas orientated stencil instructions but they don't seem to apply to child widgets. What is the best approach for this? I guess it is to customize the StencilView class but I can't see where that is implemented. Can anyone give me a push in the right direct?

Thx,

Tim

Tim Sheerman-Chase

unread,
Jul 22, 2016, 5:20:08 PM7/22/16
to Kivy users support
Ah interesting, StencilView is implemented in style.kv


<StencilView>:
    canvas.before:
        StencilPush
        Rectangle:
            pos: self.pos
            size: self.size
        StencilUse

    canvas.after:
        StencilUnUse
        Rectangle:
            pos: self.pos
            size: self.size
        StencilPop



I should be able to use that as a basis.

Tim Sheerman-Chase

unread,
Jul 22, 2016, 6:31:32 PM7/22/16
to Kivy users support
Cracked it. If anyone has suggestions to make it more canonical in kivy style, let me know.

https://gist.github.com/TimSC/473a8c5743c6e4623ee2297e49ae47dc
Reply all
Reply to author
Forward
0 new messages