L Lochana
L Lochana

Reputation: 79

How to insert a label on a image in kivy?

I am new to kivy. I have chosen a background image and i want to insert a label on it. But it shows like this.

from kivy.app import App  
from kivy.uix.image import Image 
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout

class MyApp(App):
    def build(self): 
        self.box = BoxLayout()
        self.img = Image(source = 'image4.png')
        self.lbl = Label(text = "Total_Wealth")

        self.box.add_widget(self.img)
        self.box.add_widget(self.lbl)

        return self.box

[![enter image description here][1]][1]MyApp().run()

Upvotes: 0

Views: 647

Answers (1)

Chitkaran Singh
Chitkaran Singh

Reputation: 1736

The BoxLayout automatically stacks the widgets.

If you want to put Label on top of the image, you can use FloatLayout for more control on the placement of the widgets

Upvotes: 1

Related Questions