在tkinter上查看简单的HTML文档
tkhtmlview的Python项目详细描述
tkhtmlview公司
tkinter的HTML小部件
Fork of tk_html_widgets
概述
这个模块是tkinter小部件的集合,它们的文本可以设置为HTML格式。 HTML小部件不是web浏览器框架,它只是一个简单而轻量级的HTML解析器,用于格式化tkinter文本基类所使用的标记。 widgets行为类似于PyQt5文本小部件(参见PyQt5 HTML markup subset)。在
安装
pip install tkhtmlview
要求
- Python 3.4 or later支持tcl/tk
- Pillow 5.3.0
- 请求
示例
importtkinterastkfromtkhtmlviewimportHTMLLabelroot=tk.Tk()html_label=HTMLLabel(root,html='<h1 style="color: red; text-align: center"> Hello World </H1>')html_label.pack(fill="both",expand=True)html_label.fit_height()root.mainloop()
文件
等级:
所有小部件类都继承自tkinter.文本()基类。在
类HTMLScrolledText(tkinter.文本)
Text-box widget with vertical scrollbar
类HTMLText(tkinter.文本)
Text-box widget without vertical scrollbar
类HTMLLabel(tkinter.文本)
Text-box widget with label appereance
方法:
def set_html(self,html,strip=True):
Description: Sets the text in HTML format.
Args:
- html: input HTML string
- strip: if True (default) handles spaces in HTML-like style
def fit_height(自我):
Description: Fit widget height in order to display all wrapped lines
HTML支持:
只支持整个HTML标记和属性的一个子集(见下表)。 如果有可能,我希望在下一个版本中添加更多的HTML支持。在
Tags | Attributes | Notes |
---|---|---|
a | style, href | |
b | style | |
br | ||
code | style | |
div | style | |
em | style | |
h1 | style | |
h2 | style | |
h3 | style | |
h4 | style | |
h5 | style | |
h6 | style | |
i | style | |
img | src, width, height | experimental support for remote images |
li | style | |
mark | style | |
ol | style, type | 1, a, A list types only |
p | style | |
pre | style | |
span | style | |
strong | style | |
u | style | |
ul | style | bullet glyphs only |
- 项目
标签: