【问题标题】:fit image in the button on kivy在 kivy 上的按钮中适合图像
【发布时间】:2021-10-08 12:22:58
【问题描述】:

我有一个问题,我正在用 kivy 制作一个小的应用程序界面。使用图片制作按钮时,图片部分不根据按钮缩放,但是根据按钮调整大小时,图片是倾斜的,但只需要在应用的屏幕上受到影响(放大缩小屏幕) ),图像会改变。运行到正确的位置并缩放到按钮的大小。有谁能帮助我吗? enter image description hereenter image description hereenter image description here

【问题讨论】:

  • 请将代码添加到问题中,而不是屏幕截图,而是粘贴在code标签中的文本。

标签: python image button kivy scale


【解决方案1】:

例如:

Button:
    background_color: 0, 0, 0, 0
    pos_hint: {'x': .39, 'y': .1}
    size_hint: .28, .15

    Image:
        id: my_image
        source: "name of the image"
        size: 350, 350
        allow_stretch: True
        allow_ratio: True
        keep_ratio: True
        center_x: self.parent.center_x
        center_y: self.parent.center_y

【讨论】:

    猜你喜欢
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-15
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    相关资源
    最近更新 更多