Re: [kivy-users] Re: how to change TextInput border color

17 views
Skip to first unread message
Message has been deleted
Message has been deleted

elli...@cox.net

unread,
Apr 1, 2024, 10:17:33 AMApr 1
to Kivy users support
The box drawn is an image.  The image is set by the attribute 'background_active'.  You could change the image when focus is True, or use the canvas to draw a Line around the TextInput and change the color.   https://kivy.org/doc/stable/api-kivy.uix.textinput.html#kivy.uix.textinput.TextInput.background_active

Here is an example:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.properties import ColorProperty

kv = """
<OutlineTextInput>:
    canvas.after:
        Color:
            rgba: self.focus_color if self.focus else (0, 0, 0, 0)
        Line:
            rectangle: (*self.pos, *self.size)
            width: dp(2)

AnchorLayout:
    OutlineTextInput:
        size_hint: None, None
        size: '200dp', '30dp'
        focus_color: 'lightgreen'
"""


class OutlineTextInput(TextInput):
    focus_color = ColorProperty('green')


class OutlineTextInputApp(App):
    def build(self):
        return Builder.load_string(kv)


OutlineTextInputApp().run()

From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> on behalf of Anton Chivchalov <ant...@gmail.com>
Sent: Monday, April 1, 2024 3:26 AM
To: Kivy users support <kivy-...@googlegroups.com>
Subject: [kivy-users] Re: how to change TextInput border color
 
I mean when it's focused. 

понедельник, 1 апреля 2024 г. в 13:24:59 UTC+3, Anton Chivchalov:
Hi, how does one change the color of the border of TextInput? It's always blue-green (teal). It looks like the official docs on TextInput are silent on it.

border.png

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/339f8161-9fae-463c-bc67-2972de9e88d3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages