[英]How to scale a Image of kivy toggle button and keep its aspect ratio?
Hej HEJ
I want to create my own radio button in kivy. 我想在kivy中创建自己的单选按钮。 For that I am using a template:
为此我使用模板:
<myCheckBox@ToggleButton>:
background_normal: 'gfx/cbActive.png'
background_down: 'gfx/cbInactive.png'
background_disabled_down: 'gfx/cbActive.png'
background_disabled_normal: 'gfx/cbInactive.png'
The button looks like: 按钮看起来像:
When using the template at the App it can be downscaled but the downscale process does not scale it symmetrically. 在App上使用模板时,它可以缩小尺寸,但缩小尺寸过程不会对称缩放。 It looks like:
看起来像:
Any ideas on why the downscaling isn't symmetrical? 关于为什么降尺度不对称的任何想法?
The style for Button
(and ToggleButton
) uses a BorderImage
to scale the background. Button
(和ToggleButton
)的样式使用BorderImage
来缩放背景。 This allows the standard button-type images to be used appropriately. 这允许适当地使用标准按钮型图像。 But you can easily disable this behavior by setting the border property used for scaling:
但您可以通过设置用于缩放的border属性轻松禁用此行为:
<myCheckBox@ToggleButton>:
border: 0, 0, 0, 0
background_normal: 'gfx/cbActive.png'
background_down: 'gfx/cbInactive.png'
background_disabled_down: 'gfx/cbActive.png'
background_disabled_normal: 'gfx/cbInactive.png'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.