In this video I’ll show you how to use HTML in your Tkinter app!

HTML is used to build websites, but what if you could use it in a Tkinter app? In this video I’ll show you exactly how to do that using TKHTMLView.

Not all of HTML is available for us to use in our Tkinter app, but we can use the following HTML Tags:
a – Link Tags
img src – Image Tags
h1, h2, h3, h4, h5, h6 – heading tags
ol, ul – unorderd and ordered lists
em – italics
strong – bold
br – line preaks
p – paragraph tags
div
code
pre
span
u – underline
and more!

Python Code: h1.py
(Github Code)

from tkinter import *
from tkhtmlview import HTMLLabel

root = Tk()
root.title('Codemy.com - Using HTML')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x600")

my_label = HTMLLabel(root, html="\
	<code><h1>\
	<a href='https://codemy.com'>Learn To Code!</a>\
	</h1></code>\
	<ul>\
	<li>One</li>\
	<li>Two</li>\
	<li>Three</li>\
	</ul>\
	<img src='c:/gui/images/aspen.png'>")

my_label.pack(pady=20, 
	padx=20, 
	fill="both", 
	expand=True)


root.mainloop()


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

Add comment

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

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