A fast and lightweight cross-platform webbrowser widget for Tkinter.
TkinterWeb offers bindings for the Tkhtml3 widget from http://tkhtml.tcl.tk/tkhtml.html, which enables loading HTML and CSS code into Tkinter applications.
All major operating systems running Python 3+ are supported.
TkinterWeb provides:
TkinterWeb can be used in any Tkinter application. Here is an example:
from tkinterweb import HtmlFrame #import the HTML browser
try:
import tkinter as tk #python3
except ImportError:
import Tkinter as tk #python2
root = tk.Tk() #create the tkinter window
frame = HtmlFrame(root) #create the HTML browser
frame.load_website("http://tkhtml.tcl.tk/tkhtml.html") #load a website
frame.pack(fill="both", expand=True) #attach the HtmlFrame widget to the parent window
root.mainloop()
Some other tricks, such as handling page title changes, link clicks, and navigation key presses, can be found in the HtmlFrame documentation
To install TkinterWeb, simply type pip install tkinterweb
in the command prompt or terminal.
That's it.
In order to load webpages and show images, TkinterWeb requires the following packages:
pip install pillow
)Pip will automatically install PIL when installing TkinterWeb.
TkinterWeb ships with a few classes that make it quick and easy to use.
Documentation and additional information for these classes can be found in the corresponding API refrence pages:
See https://github.com/Andereoo/TkinterWeb/blob/main/tkinterweb/docs/FAQ.md.
HTML/CSS:
:hover
and :active
are also supported. JavaScript:
Images:
TkinterWeb happily accepts contributions.
The best way to contribute to this project is to go to the issues tab and report bugs or submit a feature request. This helps 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.
Thanks to the TkinterHtml package for providing the bindings which this project is based on.
Thanks to the BRL-CAD project for providing modifications for Tkhtml on 64-bit Windows platforms.
Thanks to Google Fonts for providing the font used for generating alternate text when images fail to load.
A special thanks to everyone else who helped this project by reporting bugs, creating pull requests, and providing suggestions!