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)
This is my favourite function - the Rastrigin function.

This is my favourite function - the Rastrigin function. What sparked my curiosity and interest in the function was its complexity in terms of many local optimum points, which makes it particularly interesting and useful for testing any optimisation algorithms.

null 1 Dec 27, 2021
Function Plotter: a simple application with GUI to plot mathematical functions

Function-Plotter Function Plotter is a simple application with GUI to plot mathe

Mohamed Nabawe 4 Jan 3, 2022
Yata is a fast, simple and easy Data Visulaization tool, running on python dash

Yata is a fast, simple and easy Data Visulaization tool, running on python dash. The main goal of Yata is to provide a easy way for persons with little programming knowledge to visualize their data easily.

Cybercreek 3 Jun 28, 2021
Getting started with Python, Dash and Plot.ly for the Data Dashboards team

data_dashboards Getting started with Python, Dash and Plot.ly for the Data Dashboards team Getting started MacOS users: # Install the pyenv version ma

Department for Levelling Up, Housing and Communities 1 Nov 8, 2021
Sentiment Analysis application created with Python and Dash, hosted at socialsentiment.net

Social Sentiment Dash Application Live-streaming sentiment analysis application created with Python and Dash, hosted at SocialSentiment.net. Dash Tuto

Harrison 456 Dec 25, 2022
GD-UltraHack - A Mod Menu for Geometry Dash. Specifically a MegahackV5 clone in Python. Only for Windows

GD UltraHack: The Mod Menu that Nobody asked for. This is a mod menu for the gam

zeo 1 Jan 5, 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 Dec 26, 2022
A guide for using Bootstrap 5 classes in Dash Bootstrap Components V1

dash-bootstrap-cheatsheet This handy interactive cheatsheet makes it easy to use the Bootstrap 5 classes with your Dash app made with the latest versi

null 10 Dec 22, 2022
Custom Plotly Dash components based on Mantine React Components library

Dash Mantine Components Dash Mantine Components is a Dash component library based on Mantine React Components Library. It makes it easier to create go

Snehil Vijay 239 Jan 8, 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
Visualization Website by using Dash and Heroku

Visualization Website by using Dash and Heroku You can visit the website https://payroll-expense-analysis.herokuapp.com/ In this project, I am interes

YF Liu 1 Jan 14, 2022
A shimmer pre-load component for Plotly Dash

dash-loading-shimmer A shimmer pre-load component for Plotly Dash Installation Get it with pip: pip install dash-loading-extras Or maybe you prefer Pi

Lucas Durand 4 Oct 12, 2022
Regress.me is an easy to use data visualization tool powered by Dash/Plotly.

Regress.me Regress.me is an easy to use data visualization tool powered by Dash/Plotly. Regress.me.-.Google.Chrome.2022-05-10.15-58-59.mp4 Get Started

Amar 14 Aug 14, 2022
Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 3 May 14, 2022
Movies-chart - A CLI app gets the top 250 movies of all time from imdb.com and the top 100 movies from rottentomatoes.com

movies-chart This CLI app gets the top 250 movies of all time from imdb.com and

null 3 Feb 17, 2022
a python function to plot a geopandas dataframe

Pretty GeoDataFrame A minimum python function (~60 lines) to draw pretty geodataframe. Based on matplotlib, shapely, descartes. Installation just use

haoming 27 Dec 5, 2022
Python toolkit for defining+simulating+visualizing+analyzing attractors, dynamical systems, iterated function systems, roulette curves, and more

Attractors A small module that provides functions and classes for very efficient simulation and rendering of iterated function systems; dynamical syst

null 1 Aug 4, 2021
A Python function that makes flower plots.

Flower plot A Python 3.9+ function that makes flower plots. Installation This package requires at least Python 3.9. pip install

Thomas Roder 4 Jun 12, 2022
Simple function to plot multiple barplots in the same figure.

Simple function to plot multiple barplots in the same figure. Supports padding and custom color.

Matthias Jakobs 2 Feb 21, 2022