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

System Tray Icon for PySimpleGUI (the tkinter version). Adds a system tray icon by using pystray and PIL

psgtray Add a System Tray Icon to your tkinter port of PySimpleGUI. Installation via pip Installation is via pip: python -m pip install psgtray or if

PySimpleGUI 38 Dec 30, 2022
A Minimalistic Backup GUI for your Windows, Mac or Linux

BlobBackup is a minimalistic backup utility for your Windows, Mac or Linux computer. With an excellent engine, extensive storage support, and an easy

Bimba Shrestha 283 Nov 30, 2022
Advanced GUI Calculator with Beautiful UI and Clear Code.

Advanced GUI Calculator with Beautiful UI and Clear Code.

Mohammad Dori 3 Jul 15, 2022
Write desktop and web apps in pure Python

Flexx Want to stay up-to-date about (changes to) Flexx? Subscribe to the NEWS issue. Introduction Flexx is a pure Python toolkit for creating graphica

flexxui 3.1k Jan 08, 2023
A python Script For Taking Screenshot Of Windows

PyShot A Python Script For Taking Screenshot Of Windows Disclaimer This tool is for educational purposes only ! Don't use this to take revenge I will

Nazim Cp 2 Jun 22, 2022
GUI Pancakeswap 2 and Uniswap 3 SNIPER BOT 🥇 🏆 🥇

GUI Pancakeswap V2 and Uniswap V3 trading client (and bot) MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC (BUY TOKEN ON LAUNCH)

HYDRA 16 Dec 21, 2021
A Python based Connect 4 game made with DearPyGUI

Ultimate-Connect-4 A Python based Connect 4 game made with DearPyGUI NOTICE: If you connect to the game server hosted by Jah-On and attempt to send ma

4 Jun 01, 2022
Awesome examples for my Sun Valley ttk theme!

Sun Valley ttk theme examples This is the examples repo for my stunning Sun Valley ttk theme! Be sure to start and atch this repo, because I will uplo

rdbende 117 Jan 03, 2023
Function-Plotter - GUI Application to plot math Functions

Function Plotter GUI Application to plot a user given function How to run instal

1 May 05, 2022
Rich.tui is a TUI (Text User Interface) framework for Python using Rich as a renderer.

rich.tui Rich.tui is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich term

Will McGugan 17.1k Jan 04, 2023
The Python-Weather-App is a service that provides weather data

The Python-Weather-App is a service that provides weather data, including current weather data to the developers of web services and mobile applications.

Sayed Tabish 1 Dec 13, 2021
Randomly picks between your favourite meals for you when you're feeling indecisive.

Food Recommendations Desktop application created with python and tkinter. The goal for this application is to provide a way for users to enter and sav

Jesse Kartabani 1 Dec 07, 2021
A graphical user interface calendar with python

GUI-Calendar A graphical user interface calendar with python In this project I used tkinter module If you dont have tkinter module you can install it

Arone Sadegh 1 Dec 18, 2021
A Url Shortener with GUI made in Python.

Url-Shortener-with-GUI-in-python A Url Shortener with GUI made in Python. To Run this download the zip file and run the main file or Clone this repo.

SidTheMiner 1 Nov 12, 2021
LyricsGenerator - A simple GUI made using Python(Tkinter) for generating song lyrics

Lyrics Generator Reference :- https://www.geeksforgeeks.org/create-a-gui-to-extr

Somya Ranjan Sahu 3 Mar 25, 2022
A simple todo GUI applicaiton

simple_todo_gui A simple todo GUI applicaiton To create an .exe file, run 'Python setup.py build' after installing PyQt5 and cx_Freeze with pip. Then

Dhammike Piyumal 2 Nov 11, 2021
A Virtual Desktop Assistant Written in Python

DesktopAssitant A Virtual Desktop Assistant Written in Python. It's generally a basic virtual assistant The basic purpose of this is to make work easi

Technerd Brainiac 597 Dec 31, 2022
A library for building modern declarative desktop applications in WX.

re-wx is a library for building modern declarative desktop applications. It's built as a management layer on top of WXPython, which means you get all the goodness of a mature, native, cross-platform

Chris 115 Dec 24, 2022
Redis GUI using Qt & Python

QRedis A Python, Qt based Redis client user interface. Help wanted Open to people who want to colaborate. Would like to know which features you would

Tiago Coutinho 58 Dec 09, 2022
A Simple GUI application to organize and store accounts/passwords.

PyssView A Simple GUI application to organize and store accounts/passwords. Install/Run (Linux) Via script This way will install a binary version and

Jefferson Richard Dias 1 Nov 24, 2021