Write interactive web app in script way.

Overview

PyWebIO

Write interactive web app in script way.

Percy visual test Code coverage Jsdelivr hit count Documentation Status Package version Python Version
Python code quality Javascript code quality License
[Document] | [Demos] | [Why PyWebIO?]

English | 中文

PyWebIO provides a series of imperative functions to obtain user input and output on the browser, turning the browser into a "rich text terminal", and can be used to build simple web applications or browser-based GUI applications without the need to have knowledge of HTML and JS. PyWebIO can also be easily integrated into existing Web services. PyWebIO is very suitable for quickly building applications that do not require complex UI.

PyWebIO output demo PyWebIO input demo

Features:

  • Use synchronization instead of a callback-based method to get input
  • Non-declarative layout, simple and efficient
  • Less intrusive: old script code can be transformed into a Web application only by modifying the input and output operation
  • Support integration into existing web services, currently supports Flask, Django, Tornado, aiohttp, FastAPI framework
  • Support for asyncio and coroutine
  • Support data visualization with third-party libraries, e.g., plotly, bokeh, pyecharts.

Installation

Stable version:

pip3 install -U pywebio

Development version:

pip3 install -U https://code.aliyun.com/wang0618/pywebio/repository/archive.zip

Prerequisites: PyWebIO requires Python 3.5.2 or newer

Quickstart

Hello, world

Here is a simple PyWebIO script to calculate the BMI:

from pywebio.input import input, FLOAT
from pywebio.output import put_text

def bmi():
    height = input("Your Height(cm):", type=FLOAT)
    weight = input("Your Weight(kg):", type=FLOAT)

    BMI = weight / (height / 100) ** 2

    top_status = [(14.9, 'Severely underweight'), (18.4, 'Underweight'),
                  (22.9, 'Normal'), (27.5, 'Overweight'),
                  (40.0, 'Moderately obese'), (float('inf'), 'Severely obese')]

    for top, status in top_status:
        if BMI <= top:
            put_text('Your BMI: %.1f, category: %s' % (BMI, status))
            break

if __name__ == '__main__':
    bmi()

This is just a very simple script if you ignore PyWebIO, but using the input and output functions provided by PyWebIO, you can interact with the code in the browser [demo]:

PyWebIO demo

Serve as web service

The above BMI program will exit immediately after the calculation, you can use pywebio.start_server() to publish the bmi() function as a web application:

from pywebio import start_server
from pywebio.input import input, FLOAT
from pywebio.output import put_text

def bmi(): # bmi() keep the same
    ...  

if __name__ == '__main__':
    start_server(bmi, port=80)

Integration with web framework

To integrate a PyWebIO application into Tornado, all you need is to add a RequestHandler to the existing Tornado application:

import tornado.ioloop
import tornado.web
from pywebio.platform.tornado import webio_handler

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

if __name__ == "__main__":
    application = tornado.web.Application([
        (r"/", MainHandler),
        (r"/bmi", webio_handler(bmi)),  # bmi is the same function as above
    ])
    application.listen(port=80, address='localhost')
    tornado.ioloop.IOLoop.current().start()

Now, you can open http://localhost/bmi for BMI calculation.

For integration with other web frameworks, please refer to document.

Demos

  • Basic demo : PyWebIO basic input and output demos and some small applications written using PyWebIO.
  • Data visualization demo : Data visualization with the third-party libraries, e.g., plotly, bokeh, pyecharts.

Document

Document is on https://pywebio.readthedocs.io

Learn to build a Python Desktop GUI app using pywebview, Python, JavaScript, HTML, & CSS.

Python Desktop App Learn how to make a desktop GUI application using Python, JavaScript, HTML, & CSS all thanks to pywebview. pywebview is essentially

Coding For Entrepreneurs 55 Jan 05, 2023
Custom Widgets For PyQt5

pyqtCuWi Custom Widgets Icon Button Documentation Rank Widget Documentation PopUp OuterRadius PopUp Documentation OuterRadius Documentation Producer:

.CODE 0 Apr 04, 2022
A system tray application written in python that will assist you with your keyboard endeavors.

A system tray application written in python that will assist you with your keyboard endeavors. It has features such as abbreviation, email autofill, media control, writing from clipboard ,typing curr

Mach50 1 Dec 15, 2021
Software com funçoes de A a Z feito no Python

Introdução Iniciante em programação Python, decidi criar um programa com diversas ferramentas de A a Z. Funções Ferramenta de Gerenciamento e Manutenç

João Pedro 1 Jan 26, 2022
Key Cast - Cast your key presses and mouse clicks on the screen, while casting your favorite application on the screen. Better than the rest.

Key Cast Screen cast your keyboard and mouse clicks in style Project Homepage » View Demo · Report Bug · Request Feature Table of Contents Introductio

Mehul Singh Teya 13 Dec 23, 2022
HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities.

HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities. Looking for Artwork This project is looking for an Icon an

8 Dec 03, 2022
This simple python program can be used to make FontChooser dialog in Tkinter Applications.

tkFontBox This simple python program can be used to make FontChooser dialog in Tkinter Applications. how to use? Copy the tkFontBox.py file into your

Pawan Kumar Prachi 1 Feb 08, 2022
My Git GUI version made in Python and Tkinter.

Description My Git GUI version made in Python and Tkinter. How to use Basically, create a folder in your computer, open the software, select the path

Matheus Golzio 4 Oct 10, 2021
Make nixos usable for non-technical users through a settings / package management GUI.

Nix-Gui Make nixos usable for non-technical users through a settings / package management GUI. Motives The declarative nature of ni

547 Dec 31, 2022
Tkinker GUI for a college project.

GuiUtilities Pequeña suite de utileria con Tkinter enfocada en sistemas Linux. Lista de trabajo Crear archivo Copiar archivo a otro dir Editar con un

1hiking 2 Nov 25, 2021
A small GUI random roll call program made by Python.

A small GUI random roll call program made by Python.

Yuchen Ren 0 Feb 21, 2022
A really minimalistic operating system made using python's GUI module Tkinter.

BoxOS V1.0.0 About A really minimalistic operating system made using python's GUI module Tkinter. What seperates it from the other operating systems m

Fahim 2 Dec 08, 2022
Remi is a GUI library for Python applications that gets rendered in web browsers

Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.

Davide Rosa 3.2k Jan 07, 2023
Primeira interface (simples) desenvolvida em Python utilizando o PySimpleGUI

Interface-Python Sobre o projeto Primeira interface gráfica (simples) desenvolvida em Python utilizando o PySimpleGUI Interface Gráfica Tecnologias ut

Matheus Maia Alvarez 5 Apr 09, 2022
A GUI panel to manage multi monitor on i3wm.

Monitor manager Only for I3wm (Just for now) It's about two years that I'm using i3 as my window manager and in my experience this window manager allo

Wire.Nemo 3 Nov 06, 2021
Missing widgets and components for Qt-python

superqt! "missing" widgets and components for PyQt/PySide This repository aims to provide high-quality community-contributed Qt widgets and components

napari 0 Nov 11, 2022
Useful PDF-related productivity tool.

Luftmensch 1.4.7 (Español) | 1.4.3 (English) Version 1.4.7 (Español) released in October 2021. Version 1.4.3 (English) released in September 2021. 🏮

8 Dec 29, 2022
A calculator made using Python and Tkinter

Abacus Abacus is a calculator used to compute expressions with the operators of Addition, Subtraction, Multiplication and Division. It is named after

0 Jun 24, 2022
EZ Presence - A GUI-Python app which makes it easy to set a custom Discord Rich Presence. (BETA)

EZ Presence EZ Presence is a GUI-Python app which makes it easy to set any custom Discord Rich Presence. Using the App How to Run Since the app is in

notsniped 2 Mar 01, 2022