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]!!"			

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

2 comments

Leave a Reply to John Elder Cancel reply

Your email address will not be published. Required fields are marked *

  • 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.

John Elder