Buttons with dynamic images with kivy

0

Problem

I have a button with circular image, with the image in the ratio 1: 1, and when executing the code (below) the program generates a screen with aspect ratio of 1: 1, but it is possible to resize the screen and change its aspect ratio and size, however, the image does not grow together like the screen and takes up a smaller proportional space. I've tried setting values to size_hint: , but it distorts the image, except in a single ratio. How can I make this button adaptable in relation to any proportion and size, without distortion and with the same proportional space?

Screen generated (1: 1)

Resizedcanvas(16:9)

Code

importkivykivy.require('1.9.0')fromkivy.appimportAppfromkivy.uix.floatlayoutimportFloatLayoutfromkivy.uix.imageimportImageclassFloatingApp(App):defbuild(self):returnFloatLayout()flApp=FloatingApp()flApp.run()

.kvfile

<Botao@Button>:font_size:32color:1,1,1,1size:138,138background_normal:'bd.png'background_down:'bd1.png'background_color:0.88,0.88,0.88,1size_hint:None,None<FloatLayout>:Botao:text:"Botao"
        pos_hint: {"center_x": .5, "center_y": .5}
    
asked by anonymous 11.12.2018 / 02:23

1 answer

0

We can set the width with size_hint and height equal.

size_hint: 0.1, None
height: self.width
    
12.12.2018 / 13:03