Skip to main content

Flexible DataFrame-based GUI builder for Colab and Jupyter using ipywidgets.

Project description

Frame2App

Frame2App is a flexible DataFrame-based GUI builder for Google Colab and Jupyter Notebook using ipywidgets.

It creates interactive GUI forms from pandas DataFrames and lets users attach any custom Python function behind any button.

Main idea

DataFrame + automatic/manual/hybrid field configuration + flexible callbacks
→ notebook GUI

Features

  • Fully automatic GUI generation from a DataFrame
  • Fully manual field configuration
  • Hybrid mode: automatic for most fields, customized overrides for selected fields
  • Flexible button names
  • Flexible callback functions
  • Built-in actions: reset, clear_output, show_values, to_dataframe, validate
  • Validation support
  • Export values as dictionary, DataFrame, or JSON
  • Layouts: vertical, grid, horizontal, accordion
  • Works in Google Colab and Jupyter Notebook

Installation

pip install frame2app

For Google Colab:

!pip install frame2app
from google.colab import output
output.enable_custom_widget_manager()

Basic automatic usage

import pandas as pd
from frame2app import AutoForm

sample_df = pd.DataFrame({
    "age": [18, 25, 32, 45, 60],
    "income": [20000, 35000, 50000, 70000, 90000],
    "gender": ["Male", "Female", "Female", "Male", "Female"],
    "city": ["London", "Dublin", "Paris", "London", "Berlin"],
    "has_account": [True, False, True, True, False],
    "target": [0, 1, 0, 1, 1]
})

def run_anything(values):
    print("Values received:")
    print(values)

app = AutoForm(
    data=sample_df,
    target="target",
    title="Automatic GUI",
    buttons={
        "Run Anything": run_anything,
        "Show Values": "show_values",
        "As DataFrame": "to_dataframe",
        "Reset": "reset",
        "Clear Output": "clear_output",
    }
)

app.display()

Hybrid automatic + customized fields

app = AutoForm(
    data=sample_df,
    target="target",
    fields="auto",
    overrides={
        "age": {
            "widget": "int_slider",
            "min": 18,
            "max": 100,
            "step": 1,
            "default": 30,
        },
        "gender": {
            "widget": "radio",
            "options": ["Male", "Female"],
            "default": "Female",
        },
        "city": {
            "widget": "combobox",
            "options": ["London", "Dublin", "Paris", "Berlin", "New York"],
            "default": "London",
        },
    },
    buttons={
        "Submit": run_anything,
        "Validate": "validate",
        "Reset": "reset",
    },
    layout="grid",
    title="Hybrid Auto + Custom GUI"
)

app.display()

Fully manual fields

app = AutoForm(
    data=sample_df,
    fields={
        "age": {
            "widget": "int_slider",
            "min": 18,
            "max": 100,
            "default": 30,
            "required": True,
        },
        "income": {
            "widget": "int_text",
            "default": 50000,
            "validator": lambda value: (value >= 0, "Income must be non-negative."),
        },
        "gender": {
            "widget": "dropdown",
            "options": ["Male", "Female"],
            "default": "Male",
        },
    },
    buttons={
        "Process": run_anything,
        "Reset": "reset",
    }
)

app.display()

Supported widget names

  • int_slider
  • float_slider
  • range_slider
  • float_range_slider
  • int_text
  • float_text
  • dropdown
  • combobox
  • radio
  • select_multiple
  • checkbox
  • textarea
  • date_picker
  • password
  • file_upload
  • text
  • html

Built-in button actions

buttons={
    "Show Values": "show_values",
    "Show DataFrame": "to_dataframe",
    "Validate": "validate",
    "Reset": "reset",
    "Clear Output": "clear_output",
}

Custom button function

Every custom function receives the current form values as a dictionary.

def my_function(values):
    print(values)

app = AutoForm(
    data=sample_df,
    buttons={"Run My Function": my_function}
)

Export values

values = app.get_values()
row_df = app.to_dataframe()
json_data = app.to_json()

Local development

pip install -e .

Build

pip install build twine
python -m build

Publish

twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frame2app-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

frame2app-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file frame2app-0.1.0.tar.gz.

File metadata

  • Download URL: frame2app-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for frame2app-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9cde5ec79c9af8be432f7abcf43d651f3764aa396762fd6fe3d47d2f2d09997
MD5 68180af01bdef5b988072e2b30345bb3
BLAKE2b-256 17ad79253a40ed59d907e5f74aef876d6adcf64b2e19eea98e7b2d813dc77053

See more details on using hashes here.

File details

Details for the file frame2app-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: frame2app-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for frame2app-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab0acd764e535501d3106f56d52345f33f6af47e776c1388f738e424c490d0e6
MD5 f9bd5526a6078bf4900bfc1458efeca3
BLAKE2b-256 375e4e74728a1b3786b91f6c4cb01ced9972f74b752408a43dc0b627b5e004c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page