Generating interfaces(CLI, Qt GUI, Dash web app) from a Python function.

Overview

oneFace is a Python library for automatically generating multiple interfaces(CLI, GUI, WebGUI) from a callable Python object.

Build Status codecov Documentation Install with PyPi

oneFace is an easy way to create interfaces in Python, just decorate your function and mark the type and range of the arguments:

from oneface import one, Arg

@one
def bmi(name: Arg(str),
        height: Arg(float, [100, 250]) = 160,
        weight: Arg(float, [0, 300]) = 50.0):
    BMI = weight / (height / 100) ** 2
    print(f"Hi {name}. Your BMI is: {BMI}")
    return BMI


# run cli
bmi.cli()
# or run qt_gui
bmi.qt_gui()
# or run dash web app
bmi.dash_app()

These code will generate the following interfaces:

CLI Qt Dash
CLI Qt Dash

Features

  • Generate CLI, Qt GUI, Dash Web app from a python function.
  • Automatically check the type and range of input parameters and pretty print them.
  • Easy extension of parameter types and GUI widgets.

Detail usage see the documentation and pythondig.

Installation

To install oneFace with complete dependency:

$ pip install oneface[all]

Or install with just qt or dash dependency:

$ pip install oneface[qt]  # qt
$ pip install oneface[dash]  # dash
Comments
  • Wrap CLI

    Wrap CLI

    Wrap a CLI program to a GUI/Web interface app.

    Using a .yaml as config to specify the arguments:

    # open_browser_oneface.yaml
    name: open_browser
    
    command: python -m webbrowser {is_tab} {url} 
    
    arguments:
    
      is_tab:
        type: bool
        true_content: "-t"
        false_content: ""
    
      url:
        type: str
    

    Launch the app with:

    $ python -m onface.wrap_cli run open_browser_oneface.yaml qt_gui
    

    It will get a GUI app.

    enhancement 
    opened by Nanguage 1
  • A Thanks Message

    A Thanks Message

    Hello, i am Onur, i am a CTO of a community that develop Blockchain based Decentralized Application Network. This repository have a very good idea. All contributor of this project and me should develop this project and use in the other project. Let's not stop developing.

    Onur Atakan ULUSOY - CTO of Decentra Network Community

    opened by onuratakan 1
  • Implicit Arg convert from Python builtin types

    Implicit Arg convert from Python builtin types

    Allow type annotation with python builtin types, for example:

    from oneface import one, Arg
    
    @one
    def bmi(name: str,
            height: (float, [100, 250]) = 160,
            weight: (float, [0, 300]) = 50.0):
        BMI = weight / (height / 100) ** 2
        print(f"Hi {name}. Your BMI is: {BMI}")
        return BMI
    
    # run cli
    bmi.cli()
    

    Let the annotation automatically convert to Arg when parse the parameters.

    enhancement 
    opened by Nanguage 1
  • Integrate generated qt window to a Qt app.

    Integrate generated qt window to a Qt app.

    import sys
    from oneface.qt import qt_window
    from oneface import one
    from qtpy import QtWidgets
    
    app = QtWidgets.QApplication([])
    
    
    @qt_window
    @one
    def add(a: int, b: int):
        return a + b
    
    @qt_window
    @one
    def mul(a: int, b: int):
        return a * b
    
    
    main_window = QtWidgets.QWidget()
    main_window.setWindowTitle("MyApp")
    main_window.setFixedSize(200, 100)
    layout = QtWidgets.QVBoxLayout(main_window)
    layout.addWidget(QtWidgets.QLabel("Apps:"))
    btn_open_add = QtWidgets.QPushButton("add")
    btn_open_mul = QtWidgets.QPushButton("mul")
    btn_open_add.clicked.connect(add.show)
    btn_open_mul.clicked.connect(mul.show)
    layout.addWidget(btn_open_add)
    layout.addWidget(btn_open_mul)
    main_window.show()
    
    sys.exit(app.exec())
    
    enhancement 
    opened by Nanguage 0
  • Dash: the 'plotly' result_result_type

    Dash: the 'plotly' result_result_type

    Allow render the result with ploty. The wraped function return a plotly figure object:

    from oneface import one, Arg
    import plotly.express as px
    import numpy as np
    
    @one
    def draw_random_points(n: Arg[int, [1, 10000]] = 100):
        x, y = np.random.random(n), np.random.random(n)
        fig = px.scatter(x=x, y=y)
        return fig
    
    draw_random_points.dash_app(
        result_show_type='plotly',
        debug=True)
    
    enhancement 
    opened by Nanguage 0
  • Flask integration of dash app

    Flask integration of dash app

    Embeding the generated dash app as a route of flask server.

    # demo_flask_integrate.py
    from flask import Flask
    from oneface.dash_app import flask_route
    from oneface.core import one
    
    server = Flask("test_dash_app")
    
    @flask_route(server, "/add")
    @one
    def add(a: int, b: int) -> int:
        return a + b
    
    @flask_route(server, "/mul")
    @one
    def mul(a: int, b: int) -> int:
        return a * b
    
    server.run("127.0.0.1", 8088)
    

    Run this will launch a flask server support run multiple dash app from different route.

    References:

    • https://blog.finxter.com/dash-flask/
    enhancement 
    opened by Nanguage 0
  • Define custom dash commpont to support complex input type.

    Define custom dash commpont to support complex input type.

    For example:

    from oneface import one, Arg
    from oneface.dash_app import App, InputItem
    from dash import dcc, html
    
    class Person:
        def __init__(self, name, age):
            self.name = name
            self.age = age
    
    
    def check_person_type(val, tp):
        return (
            isinstance(val, tp) and
            isinstance(val.name, str) and
            isinstance(val.age, int)
        )
    
    Arg.register_type_check(Person, check_person_type)
    Arg.register_range_check(Person, lambda val, range: range[0] <= val.age <= range[1])
    
    class PersonInputItem(InputItem):
        def get_input(self):
            if self.default:
                default_val = f"Person('{self.default.name}', {self.default.age})"
            else:
                default_val = ""
            return dcc.Input(
                placeholder="example: Person('age', 20)",
                type="text",
                value=default_val,
                style={
                    "width": "100%",
                    "height": "40px",
                    "margin": "5px",
                    "font-size": "20px",
                }
            )
    
    
    App.register_widget(Person, PersonInputItem)
    App.register_type_convert(Person, lambda s: eval(s))
    
    
    @one
    def print_person(person: Arg(Person, [0, 100]) = Person("Tom", 10)):
        print(f"{person.name} is {person.age} years old.")
    
    
    print_person.dash_app()
    
    

    This code using the serialized input Person, how to define a "Composite components" in dash to support Person input? Just like in Qt:

    image

    question 
    opened by Nanguage 0
Releases(0.1.9)
Visualizations of linear algebra algorithms for people who want a deep understanding

Visualising algorithms on symmetric matrices Examples QR algorithm and LR algorithm Here, we have a GIF animation of an interactive visualisation of t

ogogmad 3 May 05, 2022
Data Analysis: Data Visualization of Airlines

Data Analysis: Data Visualization of Airlines Anderson Cruz | London-UK | Linkedin | Nowa Capital Project: Traffic Airlines Airline Reporting Carrier

Anderson Cruz 1 Feb 10, 2022
A python script editor for napari based on PyQode.

napari-script-editor A python script editor for napari based on PyQode. This napari plugin was generated with Cookiecutter using with @napari's cookie

Robert Haase 9 Sep 20, 2022
Data parsing and validation using Python type hints

pydantic Data validation and settings management using Python type hinting. Fast and extensible, pydantic plays nicely with your linters/IDE/brain. De

Samuel Colvin 12.1k Jan 06, 2023
Plot toolbox based on Matplotlib, simple and elegant.

Elegant-Plot Plot toolbox based on Matplotlib, simple and elegant. 绘制效果 绘制过程 数据准备 每种图标类型的目录下有data.csv文件,依据样例数据填入自己的数据。

3 Jul 15, 2022
Functions for easily making publication-quality figures with matplotlib.

Data-viz utils 📈 Functions for data visualization in matplotlib 📚 API Can be installed using pip install dvu and then imported with import dvu. You

Chandan Singh 16 Sep 15, 2022
This is a learning tool and exploration app made using the Dash interactive Python framework developed by Plotly

Support Vector Machine (SVM) Explorer This app has been moved here. This repo is likely outdated and will not be updated. This is a learning tool and

Plotly 150 Nov 03, 2022
Personal IMDB Graphs with Bokeh

Personal IMDB Graphs with Bokeh Do you like watching movies and also rate all of them in IMDB? Would you like to look at your IMDB stats based on your

2 Dec 15, 2021
Cartopy - a cartographic python library with matplotlib support

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation easy. Table of contents Overview Get in touch License an

1.2k Jan 01, 2023
Pretty Confusion Matrix

Pretty Confusion Matrix Why pretty confusion matrix? We can make confusion matrix by using matplotlib. However it is not so pretty. I want to make con

Junseo Ko 5 Nov 22, 2022
Uniform Manifold Approximation and Projection

UMAP Uniform Manifold Approximation and Projection (UMAP) is a dimension reduction technique that can be used for visualisation similarly to t-SNE, bu

Leland McInnes 6k Jan 08, 2023
A central task in drug discovery is searching, screening, and organizing large chemical databases

A central task in drug discovery is searching, screening, and organizing large chemical databases. Here, we implement clustering on molecular similarity. We support multiple methods to provide a inte

NVIDIA Corporation 124 Jan 07, 2023
Gallery of applications built using bqplot and widget libraries like ipywidgets, ipydatagrid etc.

bqplot Gallery This is a gallery of bqplot examples. View the gallery at https://bqplot.github.io/bqplot-gallery. Contributing new examples Clone this

8 Aug 23, 2022
哔咔漫画window客户端,界面使用PySide2,已实现分类、搜索、收藏夹、下载、在线观看、waifu2x等功能。

picacomic-windows 哔咔漫画window客户端,界面使用PySide2,已实现分类、搜索、收藏夹、下载、在线观看等功能。 功能介绍 登陆分流,还原安卓端的三个分流入口 分类,搜索,排行,收藏夹使用同一的逻辑,滚轮下滑自动加载下一页,双击打开 漫画详情,章节列表和评论列表 下载功能,目

1.8k Dec 31, 2022
A python visualization of the A* path finding algorithm

A python visualization of the A* path finding algorithm. It allows you to pick your start, end location and make obstacles and then view the process of finding the shortest path. You can also choose

Kimeon 4 Aug 02, 2022
Peloton Stats to Google Sheets with Data Visualization through Seaborn and Plotly

Peloton Stats to Google Sheets with Data Visualization through Seaborn and Plotly Problem: 2 peloton users were looking for a way to track their metri

9 Jul 22, 2022
Here are my graphs for hw_02

Let's Have A Look At Some Graphs! Graph 1: State Mentions in Congressperson's Tweets on 10/01/2017 The graph below uses this data set to demonstrate h

7 Sep 02, 2022
Lightspin AWS IAM Vulnerability Scanner

Red-Shadow Lightspin AWS IAM Vulnerability Scanner Description Scan your AWS IAM Configuration for shadow admins in AWS IAM based on misconfigured den

Lightspin 90 Dec 14, 2022
Easily configurable, chart dashboards from any arbitrary API endpoint. JSON config only

Flask JSONDash Easily configurable, chart dashboards from any arbitrary API endpoint. JSON config only. Ready to go. This project is a flask blueprint

Chris Tabor 3.3k Dec 31, 2022
Here I plotted data for the average test scores across schools and class sizes across school districts.

HW_02 Here I plotted data for the average test scores across schools and class sizes across school districts. Average Test Score by Race This graph re

7 Oct 27, 2021