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)
Dimensionality reduction in very large datasets using Siamese Networks

ivis Implementation of the ivis algorithm as described in the paper Structure-preserving visualisation of high dimensional single-cell datasets. Ivis

beringresearch 284 Jan 01, 2023
Editor and Presenter for Manim Generated Content.

Editor and Presenter for Manim Generated Content. Take a look at the Working Example. More information can be found on the documentation. These Browse

Manim Community 149 Dec 29, 2022
A D3.js plugin that produces flame graphs from hierarchical data.

d3-flame-graph A D3.js plugin that produces flame graphs from hierarchical data. If you don't know what flame graphs are, check Brendan Gregg's post.

Martin Spier 740 Dec 29, 2022
CLAHE Contrast Limited Adaptive Histogram Equalization

A simple code to process images using contrast limited adaptive histogram equalization. Image processing is becoming a major part of data processig.

Happy N. Monday 4 May 18, 2022
A curated list of awesome Dash (plotly) resources

Awesome Dash A curated list of awesome Dash (plotly) resources Dash is a productive Python framework for building web applications. Written on top of

Luke Singham 1.7k Jan 07, 2023
A dashboard built using Plotly-Dash for interactive visualization of Dex-connected individuals across the country.

Dashboard For The DexConnect Platform of Dexterity Global Working prototype submission for internship at Dexterity Global Group. Dashboard for real ti

Yashasvi Misra 2 Jun 15, 2021
nvitop, an interactive NVIDIA-GPU process viewer, the one-stop solution for GPU process management

An interactive NVIDIA-GPU process viewer, the one-stop solution for GPU process management.

Xuehai Pan 1.3k Jan 02, 2023
Python code for solving 3D structural problems using the finite element method

3DFEM Python 3D finite element code This python code allows for solving 3D structural problems using the finite element method. New features will be a

Rémi Capillon 6 Sep 29, 2022
Generate the report for OCULTest.

Sample report generated in this function Usage example from utils.gen_report import generate_report if __name__ == '__main__': # def generate_rep

Philip Guo 1 Mar 10, 2022
Simulation du problème de Monty Hall avec Python et matplotlib

Le problème de Monty Hall C'est un jeu télévisé où il y a trois portes sur le plateau de jeu. Seule une de ces portes cache un trésor. Il n'y a rien d

ETCHART YANG 1 Jan 06, 2022
Minimal Ethereum fee data viewer for the terminal, contained in a single python script.

Minimal Ethereum fee data viewer for the terminal, contained in a single python script. Connects to your node and displays some metrics in real-time.

48 Dec 05, 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
An animation engine for explanatory math videos

Powered By: An animation engine for explanatory math videos Hi there, I'm Zheer 👋 I'm a Software Engineer and student!! 🌱 I’m currently learning eve

Zaheer ud Din Faiz 2 Nov 04, 2021
Numerical methods for ordinary differential equations: Euler, Improved Euler, Runge-Kutta.

Numerical methods Numerical methods for ordinary differential equations are methods used to find numerical approximations to the solutions of ordinary

Aleksey Korshuk 5 Apr 29, 2022
Pyan3 - Offline call graph generator for Python 3

Pyan takes one or more Python source files, performs a (rather superficial) static analysis, and constructs a directed graph of the objects in the combined source, and how they define or use each oth

Juha Jeronen 235 Jan 02, 2023
A high performance implementation of HDBSCAN clustering. http://hdbscan.readthedocs.io/en/latest/

HDBSCAN Now a part of scikit-learn-contrib HDBSCAN - Hierarchical Density-Based Spatial Clustering of Applications with Noise. Performs DBSCAN over va

Leland McInnes 91 Dec 29, 2022
Extract data from ThousandEyes REST API and visualize it on your customized Grafana Dashboard.

ThousandEyes Grafana Dashboard Extract data from the ThousandEyes REST API and visualize it on your customized Grafana Dashboard. Deploy Grafana, Infl

Flo Pachinger 16 Nov 26, 2022
在原神中使用围栏绘图

yuanshen_draw 在原神中使用围栏绘图 文件说明 toLines.py 将一张图片转换为对应的线条集合,视频可以按帧转换。 draw.py 在原神家园里绘制一张线条图。 draw_video.py 在原神家园里绘制视频(自动按帧摆放,截图(win)并回收) cat_to_video.py

14 Oct 08, 2022
Python Data Structures for Humans™.

Schematics Python Data Structures for Humans™. About Project documentation: https://schematics.readthedocs.io/en/latest/ Schematics is a Python librar

Schematics 2.5k Dec 28, 2022
Application for viewing pokemon regional variants.

Pokemon Regional Variants Application Application for viewing pokemon regional variants. Run The Source Code Download Python https://www.python.org/do

Michael J Bailey 4 Oct 08, 2021