gpt4 book ai didi

python-3.x - 如何在 python 3.4.x 中的 tkinter 的文本小部件中显示渲染的 html 内容

转载 作者:行者123 更新时间:2023-12-03 15:51:05 26 4
gpt4 key购买 nike

我想在 python 3.4 中的 tkinter 的文本小部件中显示我的邮件。
可以使用 message.HTMLBody 以 HTML 格式打印。 .如何在我的文本小部件中呈现它并显示内容

最佳答案

我设法使用 tkhtml 呈现简单的 html 标签.
使用 pip3 install tkinterhtml 安装,然后,使用 package example :

from tkinterhtml import HtmlFrame

frame = HtmlFrame(root, horizontal_scrollbar="auto")

frame.set_content("<html></html>")

如果你想直接渲染一个网页,你可以这样做来请求和渲染它:
import urllib
frame.set_content(urllib.request.urlopen("https://duckduckgo.com").read().decode())
希望能帮助到你 :)

关于python-3.x - 如何在 python 3.4.x 中的 tkinter 的文本小部件中显示渲染的 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37084313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com