Regarding question No. 2.
How Kivy Works, Embeds Widget Instances. Since Image and Button are subclasses of Widget, then all you have to do is insert the image inside the button. Please note that the positioning inside the widget is fixed. You must specify explicit coordinates.
However, you can always embed a Layout to organize the material that you put inside the button.
Here is a simple ex
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.lang import Builder Builder.load_string(""" <ButtonsApp>: orientation: "vertical" Button: text: "B1" Image: source: 'kivy.png' y: self.parent.y + self.parent.height - 200 x: self.parent.x Label: text: "A label" """) class ButtonsApp(App, BoxLayout): def build(self): return self if __name__ == "__main__": ButtonsApp().run()
EDIT: An example of how relative layout can be embedded inside a button
In this case, I use StackLayout to organize Image and Label internally. As I said, Button is a Widget , and Kivy works with widgets inside the widget. It doesn't matter if they are shortcuts, buttons or layouts.
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.lang import Builder Builder.load_string(""" <ButtonsApp>: orientation: "vertical" Button: StackLayout: pos: self.parent.pos size: self.parent.size orientation: 'lr-tb' Image: source: 'kivy.png' size_hint_x: None width: 74 Label: size_hint_x: None width: 100 text: "The text" Label: text: "A label" """) class ButtonsApp(App, BoxLayout): def build(self): return self if __name__ == "__main__": ButtonsApp().run()
source share