In this video I’ll show you how to easily style your text in Kivy using Markup.
Markup is very similar to HTML. It has opening and closing tags, and allows you to change the style of text in Kivy. Specifically you can change:
– bold
– italics
– underline
– strikethrough
– sup
– sub
– color
– size
– font
– and more
To use markup, just set
markup: True
In the kivy element you want to use markup on. Then use the markup tags that I’ll show you in this video!
Python Code: markup.py
GitHub Code: markup.py
from kivy.app import App from kivy.uix.widget import Widget from kivy.lang import Builder # Designate Our .kv design file Builder.load_file('markup.kv') class MyLayout(Widget): pass class AwesomeApp(App): def build(self): return MyLayout() if __name__ == '__main__': AwesomeApp().run()
Kivy Design Code: markup.kv
GitHub Code: markup.kv
<MyLayout> BoxLayout: orientation: "vertical" size: root.width, root.height Label: markup: True font_size: 32 text: "This is [color=#a12c3c][b]Bold[/b][/color] [font=times]Text[/font] [sup]Up[/sup] and [sub]Down[/sub]" Label: markup: True font_size: 32 text: "This is [size=150][i]Italics[/i][/size] Text" Button: markup: True font_size: 32 text: "[u]Click[/u] [s]ME[/s]!!"
I love these tutorials! Energetic and fun teacher, clean and to the point examples, professional videos. I did not think there were any proper free Kivy resources out there – but then I discovered this. Thank you so much John for all of the work that you put into this! I just binged all 39 tutorials and I am hungry for more. This is way more fun than Netflix.
So glad you’re enjoying them! New videos every Monday morning!