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

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
UI for converting various point cloud file formats

Point cloud format converter This coverter based on open3d. If you're using old ROS1 i suggest to use conda python3 evn to install requirements. Todo

Haegu Lee 1 Oct 29, 2021
Gmail account using brute force attack

Programmed in Python | PySimpleGUI Gmail Hack Python script with PySimpleGUI for hack gmail account using brute force attack If you like it give it

Adrijan 127 Dec 30, 2022
LittlePythonGUIGuide - This is a short GUI Guide with python

This is a short GUI Guide with python, learning how to use the simple and easy moduel built into python, named tkinter.

1cy50ng3b0b 1 Nov 21, 2021
NiceGUI is an easy to use, Python-based UI framework, which renderes to the web browser.

NiceGUI NiceGUI is an easy to use, Python-based UI framework, which renderes to the web browser. You can create buttons, dialogs, markdown, 3D scences

Zauberzeug GmbH 419 Jan 09, 2023
A small pomodoro GUI for Windows/Linux created in Python with PyQt5.

Pomodoro A small pomodoro GUI for Windows/Linux created with PyQt5. Features The "Timer" tab allows you to set your desired work and rest times aswell

Burak Martin 81 Dec 28, 2022
Use CSS styling in Tkinter apps

cssTk To-Do Support Upto CSS 4.15 Set Up Docs Features * Corner Radius Gradient BG Blur Animations Usage Scenarios Allows easy import of GTK 3 and GTK

RUG 5 Oct 18, 2022
build GUIs from python functions, using magic.

magicgui: build GUIs from functions, using magic. 📖 Docs Installation magicgui uses qtpy to support both pyside2 and pyqt5 backends. However, you mus

napari 0 Nov 11, 2022
The quick and easy way to add versatile graphical interfaces with networking capabilities to your Python programs.

The quick and easy way to add versatile graphical interfaces with networking capabilities to your Python programs. Give instant access to your application to whoever you want on the Internet, without

Claude SIMON 215 Dec 28, 2022
Declarative User Interfaces for Python

Welcome to Enaml Enaml is a programming language and framework for creating professional-quality user interfaces with minimal effort. What you get A d

1.4k Jan 07, 2023
Create highly interactive web pages purely in Python

A package for building highly interactive user interfaces in pure Python inspired by ReactJS.

701 Jan 03, 2023
A Python Tkinter based Inventory managment System

Inventory Management System Using Python Tkinter Introduction Inventory managemrnt system is an open source platform for manage business. It has a com

Amit Kumar Datta 2 Oct 14, 2021
Dress up your code with a beautiful graphical user interface !

Dresscode Dress up your code with a beautiful graphical user interface ! This project is part of the Pyrustic Ecosystem. Look powered by the cyberpunk

20 Aug 24, 2022
Basic browser based on PyQt5

goneDev-browser "basic browser based on PyQt5" This application is primarily built on macOS with more adaptibility for MacOS than Windows. v1.0 will s

Harsh ADV) 1 Jan 19, 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
psgresizer - a PySimpleGUI application that will resize your images and BASE64 encode them.

psgresizer A PySimpleGUI Application Resize your images quickly and easily with this GUI application. Resizes and encodes to Base64 so that the result

PySimpleGUI 10 Dec 25, 2022
`rosbag filter` with Gooey-based GUI

rosbag_filter_gui rosbag filter with Gooey-based GUI Test-passed Ubuntu 20.04 ROS Noetic Python 3.8 Installation

Yujie He 2 Dec 07, 2021
GUI to enable user selection of measurement and station in kHTConnector module.

kHTGui GUI to enable user selection of measurement and station in kHTConnector module. Helper tool for PowerBI users If you're planning to import data

kk 1 Jan 26, 2022
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
This a pythonTkinter GUI with sqlite3 Project.

FootballGym_MIS This a pythonTkinter GUI with sqlite3 Project. This software is useful if you want to enjoy running a gym. It helps you know which tea

Hikmatullah Mohammadi 2 Jun 19, 2022