如何在 python 3.4.x 中的 tkinter 的文本小部件中显示渲染的 html 内容 [英] How to display rendered html content in text widget of tkinter in python 3.4.x
本文介绍了如何在 python 3.4.x 中的 tkinter 的文本小部件中显示渲染的 html 内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 python 3.4 中的 tkinter 文本小部件中显示我的邮件.它可以使用 message.HTMLBody
以 HTML 格式打印.如何在我的文本小部件中呈现它并显示内容
I want to display my mails as it is in text widget of tkinter in python 3.4.
It can be printed as HTML formatted way by using message.HTMLBody
. How do I render it in my text widget and display the content
推荐答案
我已经设法使用 tkhtml.
使用 pip3 install tkinterhtml
安装,然后使用 包示例:
Install using pip3 install tkinterhtml
, then, using the package example:
from tkinterhtml import HtmlFrame
frame = HtmlFrame(root, horizontal_scrollbar="auto")
frame.set_content("<html></html>")
如果你想直接渲染一个网页,你可以这样做来请求并渲染它:
If you want to directly render a webpage, you can do this to request and render it:
import urllib
frame.set_content(urllib.request.urlopen("https://duckduckgo.com").read().decode())
希望有帮助:)
这篇关于如何在 python 3.4.x 中的 tkinter 的文本小部件中显示渲染的 html 内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文