Python 如何更改进度条kivy的颜色
我是kivy的新手,我无法在进度条kivy上添加自定义颜色,请帮助我实现这一点Python 如何更改进度条kivy的颜色,python,progress-bar,kivy,Python,Progress Bar,Kivy,我是kivy的新手,我无法在进度条kivy上添加自定义颜色,请帮助我实现这一点 ProgressBar: id: pb size_hint:dp(.9),dp(.4) background_color:"#22222" #value: (app.time * 20) % 100. value:
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}
使用并更改源代码
ProgressBar
没有属性background\u color
。它使用边界图像。第一个BorderImage
(例如blue.png)用作轨道,第二个BorderImage
(例如red.png)在轨道上运行
试验电压(千伏)
#:kivy 1.11.0
:
进度条:
id:pb
最高:1000
画布:
边框图像:
边界:(12,12,12,12)
位置:自x、自中心y-12
尺寸:自宽,24
来源:“blue.png”
边框图像:
边框:[int(最小值(self.width*(self.value/float(self.max))如果self.max否则为0,12))]*4
位置:自x、自中心y-12
大小:self.width*(self.value/float(self.max))如果self.max,则为0,24
资料来源:“red.png”
输出
它不会更改条形图,而是更改进度的背景。您对更改背景颜色或条形图有何疑问?
#: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'