Fast and lightweight web browser, rich text, and app design widgets for Tkinter.
TkinterWeb adds HTML and CSS rendering capabilities to Tkinter widgets.
Common use cases include displaying help files, documentation, and other HTML content, rendering images (including SVG), building rich-text editors, designing apps with HTML templates, and creating more modern-looking interfaces, with advanced styling and even round buttons!
All major operating systems running Python 3.2+ are supported.
TkinterWeb provides:
- A frame widget to display and edit websites, help files, RSS feeds, and any other styled HTML in Tkinter.
- A label widget that can display styled HTML.
- A text widget that allows the user to edit styled HTML.
TkinterWeb can be used in any Tkinter application to display and edit websites, help pages, documentation, and much more! Here is an example:
import tkinter as tk
from tkinterweb import HtmlFrame # import the HtmlFrame widget
root = tk.Tk() # create the Tkinter window
frame = HtmlFrame(root) # create the HtmlFrame widget
frame.load_website("https://tkinterweb.readthedocs.io/en/latest/index.html") # load a website
frame.pack(fill="both", expand=True) # attach the HtmlFrame widget to the window
root.mainloop()
See Getting Started for more tips and tricks.
To install TkinterWeb, simply type pip install tkinterweb[recommended] in the command prompt or terminal. That's it!
Or, you can also choose from the following extras: pip install tkinterweb[html,images,svg,javascript,requests]. You can also use pip install tkinterweb[full] to install all optional dependencies or pip install tkinterweb to install the bare minimum.
TkinterWeb offers bindings and extensions to a modified version of the Tkhtml3 widget from http://tkhtml.tcl.tk. Tkinter and the TkinterWeb-Tkhtml package are required.
I also strongly recommended installing the following:
- TkinterWeb-Tkhtml-Extras (for better HTML/CSS support and bug fixes)
- PIL (for better image support)
- PIL.ImageTk
You can also choose from the following list for extra functionality:
- Brotli (for faster page loads on some sites)
- PythonMonkey (for basic JavaScript support)
- CairoSVG or PyGObject (for SVG support)
Pip will automatically install dependencies when installing TkinterWeb. PIL.ImageTk should be automatically installed with PIL but might need to installed separately on some systems.
Warning
The API changed significantly in version 4.0.0. See the changelog for details.
Documentation and additional information on built-in classes can be found in the corresponding API reference pages:
tkinterweb.Demotkinterweb.HtmlFrametkinterweb.HtmlLabeltkinterweb.HtmlTexttkinterweb.HtmlParsetkinterweb.TkinterWebtkinterweb.Notebook(a Tkhtml-compatible drop-in replacement forttk.Notebook)
See Frequently Asked Questions.
HTML & CSS:
- TkinterWeb supports HTML 4.01 and CSS 2.1. A full list of supported CSS declarations can be found at http://tkhtml.tcl.tk/support.html.
- Most CSS pseudo-elements, such as
:hoverand:activeare also supported. - On 64-bit Windows and Linux, if the TkinterWeb-Tkhtml-Extras is installed, HTML5 tags and some extra CSS properties (including
border-radiusandoverflow-x) and cursors are also supported. To use these features on all other platforms, you will simply need to compile Tkhtml yourself. Visit and clone https://github.com/Andereoo/TkinterWeb-Tkhtml. Then runpython compile.py --install.
JavaScript:
- Javascript only partly supported at the moment.
- To use JavaScript, PythonMonkey must be installed.
- It is also possible for the user to connect their own JavaScript interpreter or manipulate the document through Python.
- See Using JavaScript for more information and DOM Manipulation with TkinterWeb for information on manipulating the document through Python.
Images:
- TkinterWeb supports nearly 50 different image types through PIL.
- In order to load Scalable Vector Graphic images, CairoSVG, both PyCairo and PyGObject, or both PyCairo and Rsvg must also be installed.
☕ If you’d like to support ongoing development and maintenance, please consider supporting this project by buying me a coffee. Any amount is hugely appreciated!
This project is released under the MIT License and is free to use, including for commercial purposes.
If you use this project in a commercial product or derive financial benefit from it, please kindly consider supporting its development with a donation. This helps cover maintenance time and ongoing improvements, which in turn will improve your own software!
The best ways to contribute to this project are by submitting a bug report to report bugs or suggest new features, or by submitting a pull request to offer fixes. Your help makes TkinterWeb become more stable and full-featured!
Please check the FAQs and closed bugs before submitting a bug report to see if your question as already been answered.
TkinterWeb is powered by the Tkhtml project.
Special thanks to Christopher Chavez, Zamy846692, Jośe Fernando Moyano, Bumshakalaka, Trov5, Mark Mayo, Jaedson Silva, Nick Moore, Leonardo Saurwein, and Hbregalad for their code suggestions and pull requests.
Special thanks to Christopher Chavez, Jan Nijtmans, and everyone else in the tcl-core mailing list for the help making border rounding work on Windows and MacOSX, and to Zamy846692 for spearheading experimental Tkhtml development.
Thanks to the TkinterHtml package for providing the bindings on which this project is based and the BRL-CAD project for providing modifications for Tkhtml on 64-bit Windows.
A huge thanks to everyone else who supported this project by reporting bugs and providing suggestions!


