更改圆形文本输入中的颜色 python kivy

问题描述 投票:0回答:1

我创建了一个圆角的TextInput,但是我只能更改通用面板的颜色,我想单独更改TextInput中的文本颜色,以便即使使用不透明的RoundedRectangle窗口也能更好地看到

如果我将命令更改为

rgba: .4, .2, .8, 1
,即删除透明度,则文本将根本不可见

测试.py:

'''

from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder

class Screeen(Screen):
    pass
class Manager(ScreenManager):
    pass

sm = Builder.load_file("test.kv")
class appApp(App):

    def build(self):
        return sm


if __name__ == "__main__":
    appApp().run()

'''

测试.kv:

'''

Manager:
    Screeen:

<RoundedTextInput@TextInput> 
    background_color: 0,0,1,0
    canvas.before:
        Color:
            rgba: .4, .2, .8, .5
        RoundedRectangle:
            size: self.size
            pos: self.pos
            radius: [24]


<Screeen>:
    name: "Screeen"
    FloatLayout:
        size: root.width, root.height
        RoundedTextInput:
            size_hint: (.45, .1)
            pos: root.width * 1 / 4 , root.height * 1 / 2

'''

python colors kivy textinput
1个回答
0
投票

如果有人也有这个问题,我就找到了答案。我稍微改变了代码:

测试.kv:

Manager:
    Screeen:

<RoundedTextInput@TextInput>
    background_color: 0,0,1,0
    canvas.before:
        Color:
            rgba: .4, .2, .2, 1   # here change color TEXT


<Screeen>:
    name: "Screeen"
    FloatLayout:
        size: root.width, root.height


        BoxLayout:
            size_hint: (.45, .1)
            pos: root.width * 1 / 4 , root.height * 1 / 2
            canvas.after:
                Color:
                    rgba: .2, .2, 1, 1 # here change color background textinput
                RoundedRectangle:
                    size: self.size
                    pos: self.pos
                    radius: [24]
        RoundedTextInput:
            size_hint: (.45, .1)
            pos: root.width * 1 / 4 , root.height * 1 / 2
© www.soinside.com 2019 - 2024. All rights reserved.