当小部件大小与存储图像的尺寸不同时图像失真

Image distorted when widget size differs from dimensions of stored image

我有一个像这样的方形按钮:

from kivy.app import App
from kivy.uix.button import Button


class MyTestApplication(App):
    def build(self):
        b = Button(size_hint=(None, None), height=200, width=200,
                   background_normal='my_icon.png')

        return b

MyTestApplication().run()

当我使用与存储图像不同的按钮尺寸时,我设置为按钮背景的图像失真。

图片my_icon.png是这样的:

当我使用 height=100width=100 时(这些是 my_icon.png) 它看起来符合预期。

然而,当我使用更小或更大的值时,我得到以下结果:

问题:
是什么导致了这种失真,我该如何解决?

失真是由 border 属性引起的,可以通过将其设置为 border=(0, 0, 0, 0) 来修复。 更多信息在这里: https://kivy.org/docs/api-kivy.uix.button.html#kivy.uix.button.Button.border