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()
Add comment