mark up weird behavior

17 views
Skip to first unread message

maxi ichazo

unread,
Mar 6, 2020, 12:04:31 PM3/6/20
to Kivy users support

Hello,


I’m struggling with a very simple thing. I’ve read the documentation and searched in Google but couldn’t find a solution.


I’ve got a text in a Button with some mark up portions. It works fine for the first mark up instruction, but not for the rest of the mark up instruction.

Below  is a simple code that it’s not working on my machine (Windows 10 – Python 3.7 with latest Kivy version). If someone can help, it would be great!

 

Thank you,

 

Maxi


#---------------------------------------


from kivy.app import App

from kivy.uix.boxlayout import BoxLayout

from kivy.lang import Builder


kv = """


<Label>:

    markup: True

    color: 0,0,0,1


<MyWidget>:

    orientation: 'vertical'    

    Button:

        text: 'This work [color=FF0000]but not this[/color]'

    Button:

        text: '[color=FF0000]This work[/color] but not this'

    Button:

        text: '[b]working[/b]not working'

"""    


Builder.load_string(kv)    


class MyWidget(BoxLayout):

    pass


class MyButtonsApp(App):

    def build(self):

        return MyWidget()    


if __name__ == '__main__':

    MyButtonsApp().run()


embryo

unread,
Mar 6, 2020, 12:27:30 PM3/6/20
to Kivy users support
Well, it does work..

E.g. to make the whole text red, you have to enclose all of it between the markup tag (here the color one)
'[color=FF0000]This work and this too[/color]'

maxi ichazo

unread,
Mar 6, 2020, 2:02:31 PM3/6/20
to Kivy users support
I haven't explained well the issue. I want parts with mark ups and parts in normal text. The issue is that after using the first part with markups, the second part does not appear on the screen (or it is not visible).

For example:
text: '[color=FF0000]This work[/color] but not this'

I only can see the part "This work" while the second part is not on visible.

Same thing if I use [b] or change the fonts.

Maxi

Elliot Garbus

unread,
Mar 7, 2020, 9:32:35 AM3/7/20
to kivy-...@googlegroups.com

It works for me.  I would recommend adding a ‘-‘ as below:

<Label>:
    -markup: True
    -color: 0,0,0,1

 

See: https://kivy.org/doc/stable/api-kivy.lang.html?highlight=lang#redefining-a-widget-s-property-style

--
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/68763f63-ba53-4a64-bfdb-76718a733bc6%40googlegroups.com.

 

maxi ichazo

unread,
Mar 11, 2020, 5:32:03 PM3/11/20
to Kivy users support
Finally, I couldn't make it work. In my last attempt I've unistalled kivy and reinstalled everything and ---voilà!!! it worked.

Thank you

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages