Skip to main content

HTML/CSS viewer for Tkinter - bindings for Tkhtml3

Project description

TkinterWeb

A fast and lightweight cross-platform webbrowser widget for Tkinter.

   

Overview

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 2.6+ or Python 3+ are supported.

   

Usage

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()

TkinterWeb

Some other tricks, such as handling page title changes, link clicks, and navigation key presses, can be found in the HtmlFrame documentation

   

Installation

To install TkinterWeb, simply type pip install tkinterweb in the command prompt or terminal. That's it.

   

Dependencies

In order to load webpages and show images, TkinterWeb requires the following packages:

  • Tkinter (which is automatically packaged with most Python installations)
  • PIL (can be installed via pip install pillow)
  • PIL.ImageTk (may be automatically installed with PIL on some systems, otherwise needs to be installed)

Pip will automatically install PIL when installing TkinterWeb.

   

API documentation

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:

   

FAQs

See https://github.com/Andereoo/TkinterWeb/blob/main/tkinterweb/docs/FAQ.md.

   

Webpage Compatability

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 :hover and :active are also supported.

JavaScript:

  • Javascript is not supported at the moment.

Images:

  • TkinterWeb supports nearly 50 different image types through PIL. Scalable Vector Graphic support is not as straightforward, though. In order to load SVG images:
    • PyCairo or PyGObject must be installed.
    • Either Rsvg, PyGObject, or CairoSVG must also be installed.
  • Without these packages, TkinterWeb will still function properly, but SVG files will not be shown.

   

Contributing

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.

   

Credits

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 and providing suggestions!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkinterweb-3.23.4.tar.gz (37.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page