kivymd by default text color

17 views
Skip to first unread message

Degenerate Tech

unread,
Mar 31, 2024, 9:25:37 AMMar 31
to Kivy users support
i have a simple app . i want to change text color (say,  red) before that i want to copy default text color  and
i want text color according to theme dark or light .
so after changing text color to red again i can set default text color according to theme
.


####### see this code text color  showing None
from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
MDScreen:
    md_bg_color: self.theme_cls.backgroundColor
    BoxLayout:
        orientation:'vertical'


        MDLabel:
            text: "MDLabel"
            halign: "center"
            id:lbl


        Button:
            size_hint:None,None
            size:'48dp','48dp'
            on_release:app._call()
'''


class Example(MDApp):
    def build(self):
       
        return Builder.load_string(KV)
   
    def _call(self):
        self.theme_cls.theme_style = "Dark" if self.theme_cls.theme_style=='Light' else 'Light'
        print(self.root.ids.lbl.text_color)


if __name__=='__main__':

    Example().run()

elli...@cox.net

unread,
Mar 31, 2024, 3:01:27 PMMar 31
to Kivy users support
The KivyMD MDLabel, is derived from the Kivy Label.  The text color of a label is store in the attribute "color"
print(self.root.ids.lbl.color)


From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> on behalf of Degenerate Tech <sksah...@gmail.com>
Sent: Sunday, March 31, 2024 6:25 AM
To: Kivy users support <kivy-...@googlegroups.com>
Subject: [kivy-users] kivymd by default text color
 
--
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/a4fd8a3c-ebcc-4a69-89ef-698f262f9679n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages