如何使用kv语言将kivy微调器按钮设置为自己的按钮类

时间:2015-01-27 15:35:42

标签: python kivy

我想在微调器UI中设置按钮。下面是一些伪示例:

<TemplButton@Button>:
    background_normal: 'gfx/button_bgr.png'
    background_down: 'gfx/button_act.png'

<TemplSpinner@Spinner>:
    background_normal: 'gfx/button_bgr.png'
    background_down: 'gfx/button_act.png'
    dropdown_cls: TemplButton
    option_cls: TemplButton

欢迎任何帮助!

1 个答案:

答案 0 :(得分:0)

尝试使用Factory访问动态类+创建SpinnerOption(Button)类的子类

#:import Factory kivy.factory.Factory
<TemplButton@Button>:
    background_normal: 'gfx/button_bgr.png'
    background_down: 'gfx/button_act.png'

<TemplSpinnerOption@SpinnerOption>
    background_normal: 'gfx/button_bgr.png'
    background_down: 'gfx/button_act.png'

<TemplSpinner@Spinner>:
    background_normal: 'gfx/button_bgr.png'
    background_down: 'gfx/button_act.png'
    option_cls: Factory.TemplSpinnerOption