Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing image object as a button background in Kivy

Tags:

python

kivy

In Kivy, is there a way to pass image object as a button background, instead of image file name?

button.background_normal property accepts only strings. I would like to customize image properties, such as allow_stretch = False.

If that succeeds, how can I specify image alignment inside a button, eg. to make it top-left aligned?

like image 981
blablatros Avatar asked Jun 30 '13 15:06

blablatros


2 Answers

You can use

Button:

  id:mybutton

  background_down: "bgdown.png"

  background_normal: "bg.png"
like image 126
Shivanshu Surya Avatar answered Oct 16 '22 03:10

Shivanshu Surya


In addition to toto_tico's answer, you can locate the image at the center of the button as:

Button:
    id: myButton
    Image:
        source: "./buttonImage.PNG"
        center_x: self.parent.center_x
        center_y: self.parent.center_y
like image 33
Guray Yildirim Avatar answered Oct 16 '22 03:10

Guray Yildirim