Skip to content Skip to sidebar Skip to footer

Python: How Can I Render HTML Code And Show The Result To The User?

I'm building a python app that should get a certain HTML code, render it and display the result to the user in a tkinter gui. How can I do that? I would prefer having some built-in

Solution 1:

I've managed to render simple html tags using tkhtml

just pip3 install tkinterhtml

and, from the package example:

from tkinterhtml import HtmlFrame
import tkinter as tk

root = tk.Tk()

frame = HtmlFrame(root, horizontal_scrollbar="auto")
 
frame.set_content("<html></html>")

frame.set_content(urllib.request.urlopen("http://thonny.cs.ut.ee").read().decode())

Hope it helps :)


Solution 2:

Save your HTML to a file location, and use the webbrowser module's open() function to display it; see https://docs.python.org/2/library/webbrowser.html for documentation.


Post a Comment for "Python: How Can I Render HTML Code And Show The Result To The User?"