Button:
background_normal: 'teaflav/Crushes.png'
height: 40
Don’t use a button.
Combine ButtonBehavior and Image to create an Image button. Then you can use the image attributes, keep_ratio, allow stretch to control the image.
See:
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a3d62f63-f064-4896-b6e2-fb9f5926f718o%40googlegroups.com.
Don’t use a button.
Combine ButtonBehavior and Image to create an Image button. Then you can use the image attributes, keep_ratio, allow stretch to control the image.
See:
From: Stuart
Sent: Sunday, December 27, 2020 10:13 PM
To: Kivy users support
Subject: [kivy-users] How to resize a image inside a button in kivy?
Hi all
I am new to Kivy, can anyone help me with this ?
I am trying to use kivy and scrollview. I need to stop the button background image from stretching?
I am using background_normal to add a image to the button, How do I scale the image and stop it from stretching?
.kv
Button:
background_normal:
'teaflav/Crushes.png'height:
40
any help would be good, Thank you :)
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
On Dec 27, 2020, at 11:08 PM, Stuart <snor...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/466c3cb7-6334-4738-a6f2-e5983b1874c1o%40googlegroups.com.
Here is a standalone running example. I replaced your image with one I had, you will need to replace the image.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
kv = """
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
ScreenManager:
transition: FadeTransition()
MainScreen:
name: "main"
AnotherScreen:
name: 'other'
<AnotherScreen@Screen>:
Button:
text: 'Return to Main'
on_release: root.manager.current = 'main'
<MainScreen@Screen>:
BoxLayout:
ScrollView:
GridLayout:
id: container_y
size_hint_y: None
cols: 2
row_default_height: root.height*0.3
height: self.minimum_height
Image:
source: "drink.png"
ImageButton:
source: 'drink.png'
on_release: app.root.current ="other"
size_hint_y: None
height: 40
ImageButton:
source: 'drink.png'
on_release: app.root.current ="other"
size_hint_y: None
height: 40
ImageButton:
source: 'drink.png'
on_release: app.root.current ="other"
size_hint_y: None
height: 40
ImageButton:
source: 'drink.png'
on_release: app.root.current ="other"
size_hint_y: None
height: 40
ImageButton:
source: 'drink.png'
on_release: app.root.current ="other"
size_hint_y: None
height: 40
"""
class ImageButton(ButtonBehavior, Image):
pass
class ImageButtonApp(App):
def build(self):
return Builder.load_string(kv)
ImageButtonApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61A85B3B-04FD-4D91-B51A-8AA4C421F9A9%40cox.net.