Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change color of progress bar kivy

I am new in kivy i can not add customise colour on progress bar kivy please help me to implement this

 ProgressBar:
                    id: pb
                    size_hint:dp(.9),dp(.4)
                    background_color:"#22222" 
                    #value: (app.time * 20) % 100.
                    value: 50
                    pos_hint: {"right": 1, "top": .65}
like image 447
NILoy Avatar asked Sep 17 '25 06:09

NILoy


1 Answers

Use BorderImage and change the source.

There is no attribute, background_color for ProgressBar. It uses BorderImages. The first BorderImage (e.g. blue.png) acts as a rail/track whereby the second BorderImage (e.g. red.png) runs on the rail/track.

test.kv

#:kivy 1.11.0

<Rootwidget>:
    ProgressBar:
        id: pb
        max: 1000

        canvas:
            BorderImage:
                border: (12, 12, 12, 12)
                pos: self.x, self.center_y - 12
                size: self.width, 24
                source: 'blue.png'
            BorderImage:
                border: [int(min(self.width * (self.value / float(self.max)) if self.max else 0, 12))] * 4
                pos: self.x, self.center_y - 12
                size: self.width * (self.value / float(self.max)) if self.max else 0, 24
                source: 'red.png'

Output

Img01

like image 159
ikolim Avatar answered Sep 19 '25 14:09

ikolim