Giter VIP home page Giter VIP logo

tkhtmlview's Introduction

tkhtmlview

FOSSA Status

HTML widgets for tkinter

Fork of tk_html_widgets

Overview

This module is a collection of tkinter widgets whose text can be set in HTML format. A HTML widget isn't a web browser frame, it's only a simple and lightweight HTML parser that formats the tags used by the tkinter Text base class. The widgets behaviour is similar to the PyQt5 text widgets (see the PyQt5 HTML markup subset).

Installation

pip install tkhtmlview

Requirements

Example

import tkinter as tk
from tkhtmlview import HTMLLabel

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

Documentation

Classes:

All widget classes inherits from the tkinter.Text() base class.

class HTMLScrolledText(tkinter.Text)

Text-box widget with vertical scrollbar

class HTMLText(tkinter.Text)

Text-box widget without vertical scrollbar

class HTMLLabel(tkinter.Text)

Text-box widget with label appereance

Methods:

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

Description: Fit widget height in order to display all wrapped lines

HTML support:

Only a subset of the whole HTML tags and attributes are supported (see table below). Where is possibile, I hope to add more HTML support in the next releases.

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

License

FOSSA Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.