Skip to main content

GUI library for browser-based desktop applications

Project description

https://img.shields.io/pypi/v/wdom.svg https://img.shields.io/pypi/pyversions/wdom.svg https://travis-ci.org/miyakogi/wdom.svg?branch=dev https://codecov.io/github/miyakogi/wdom/coverage.svg?branch=dev

WDOM is a python GUI library for browser-based desktop applications. WDOM controls HTML elements (DOM) on browser from python, as if it is a GUI element. APIs are same as browser DOM, but of course, you can write logic codes in python.

This library includes web-server (tornado/aiohttp), but is not intended to be used as a web framework, please use for Desktop GUI Applications!

Disclaimer

WDOM is in early development stage, and may contain many (critical) bugs. All APIs are not stable and may be changed in future release.

Features

  • Pure python implementation

  • APIs based on DOM specification

    • Not need to learn new special classes/methods for GUI

    • Implemented DOM features are listed in Wiki page

  • Theming with CSS frameworks (see ScreenShots on Wiki)

  • JavaScript codes are executable on browser

  • Testable with browsers and Selenium WebDriver

  • Licensed under MIT licence

Requirements

Python 3.4.4+ and any modern-browsers are required. Also supports Electron and PyQt’s webkit browsers. IE is not supported, but most of features will work with IE11 (but not recomended).

Installation

Install by pip:

pip install wdom

Or, install latest version from github:

pip install git+http://github.com/miyakogi/wdom

As WDOM depends on tornado web framework, it will be installed automatically. Optionally supports aiohttp, which is a web framework natively supports asyncio and is partly written in C. Using aiohttp will result in better performance. If you want to use WDOM with aiohttp, install it with pip:

pip install aiohttp

Any configurations are not required; when aiohttp is available, WDOM will use it automatically.

Example

Simple example:

import asyncio
from wdom.document import get_document
from wdom.server import start_server, stop_server

if __name__ == '__main__':
    document = get_document()
    h1 = document.createElement('h1')
    h1.textContent = 'Hello, WDOM'
    document.body.appendChild(h1)

    start_server()
    try:
        asyncio.get_event_loop().run_forever()
    except KeyboardInterrupt:
        stop_server()

Execute this code and access http://localhost:8888 by browser. "Hello, WDOM" will shown on the browser. To stop process, press CTRL+C.

As you can see, methods of WDOM (document.createElement and document.body.appendChild) are very similar to browser JavaScript.

WDOM provides some new DOM APIs (e.g. append for appending child) and some tag classes to easily generate elements:

import asyncio
from wdom.tag import H1
from wdom.document import get_document
from wdom.server import start_server, stop_server

if __name__ == '__main__':
    document = get_document()
    h1 = H1()
    h1.textContent = 'Hello, WDOM'
    document.body.append(h1)

    start_server()
    try:
        asyncio.get_event_loop().run_forever()
    except KeyboardInterrupt:
        stop_server()

Of course, WDOM can handle events:

import asyncio
from wdom.tag import H1
from wdom.server import start_server, stop_server
from wdom.document import get_document

if __name__ == '__main__':
    document = get_document()
    h1 = H1('Hello, WDOM', parent=document.body)
    def rev_text(event):
        h1.textContent = h1.textContent[::-1]
    h1.addEventListener('click', rev_text)
    start_server()
    try:
        asyncio.get_event_loop().run_forever()
    except KeyboardInterrupt:
        stop_server()

When string "Hello, WDOM" is clicked, it will be flipped.

More documents are in preparation, but you can see them in docs directory of this repository.

Contributing

Contributions are welcome!!

If you find any bug, or have any comments, please don’t hesitate to report to issues on GitHub. All your comments are welcome!

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

wdom-0.1.2.tar.gz (200.4 kB view details)

Uploaded Source

File details

Details for the file wdom-0.1.2.tar.gz.

File metadata

  • Download URL: wdom-0.1.2.tar.gz
  • Upload date:
  • Size: 200.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wdom-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6798bdf022d4eefd0578c4c2a9ab05e74ef2fc8cad52eb7305d490a9b183c041
MD5 b0f883a6a2fdcebe62b31a5d7f9b8b76
BLAKE2b-256 425c40f17b4fae066b4d54ffe310664f12d9f247640580719a092215f6af6d0d

See more details on using hashes here.

Supported by

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