我是新手。我在图像上插入了标签。但是它没有显示标签的颜色。它仅显示文本,如图中所示。如果可以的话,请告诉我如何显示标签的颜色。
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
Builder.load_string("""
<Money_Manager>:
Image:
source:'image4.png'
SmoothLabel:
text: "Hello[![enter image description here][1]][1] World"
size: 0.1,.1
rgb: (255,255,255)
<SmoothLabel@Label>
background_normal: ''
border_radius: [18]
canvas.before:
Color:
rgba: (255,255,255, 1)
RoundedRectangle:
size: .1,.1
pos: self.pos
radius: self.border_radius
""")
class Money_Manager(App, FloatLayout):
def build(self):
return self
Money_Manager().run()
答案 0 :(得分:1)
嘿,您是要把Hello World标签从白色涂成其他颜色吗?
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
Builder.load_string("""
<Money_Manager>:
Image:
source:'image4.png'
SmoothLabel:
text: "Hello World"
size: 0.1,.1
color: [255,100,0,1]
<SmoothLabel@Label>
background_normal: ''
border_radius: [18]
canvas.before:
Color:
rgba: (255,0,0, 1)
RoundedRectangle:
size: .1,.1
pos: self.pos
radius: self.border_radius
""")
class Money_Manager(App, FloatLayout):
def build(self):
return self
Money_Manager().run()
您的代码行几乎没有变化
rgb: (255,255,255)
到
color: [255,100,0,1]
我可以将其涂成绿色。这就是你想要的吗。