Skip to main content

GuiGen

Project description

GUI Generator

Are you lazy programmer who wants to have GUIs for his apps but does not want to create one for each app individually? Don't worry so am I. That's why I've spent couple of hours working on automatic GUI generator, instead of creating basic copy-paste GUI in 30 minutes.

The rules are simple:

  1. Make one function for each process you want to have.
  2. Register this function as Process class.
  3. Register all instances of Process in App class instance.
  4. Use app.build() and after a little bit of waiting a GUI will pop up!

Is it slow? Perhaps.
Does it work for complex apps? Nope.
Will it fail you once upon a time? Maybe.
Was it "tHorOUgHly TEstEd"? Hell nah.
Is it easy to use? Can it gather all your small scripts in one elegant GUI? Will it save you from going insane while trying to center a div? Very much yes, sir!

Example use case 1

from gui_gen import App, Process, arguments
from time import sleep
from datetime import datetime


def my_proc(
    a1: arguments.Argument,
    a2: arguments.Float,
    a3: arguments.Int,
    a4 = 1,
    a5: int = 1  # base types are supported, if no input_template is found for specific type hint, it will defalt to arguments.Argument (str)
):
    sleep(10)
    return datetime.now()

pr = Process(
    my_proc
)

class CustomRegex(arguments.Regex):
    pattern = r'[\d]*'

def my_proc2(
    a1: arguments.Argument,
    a2: arguments.Float,
    text: CustomRegex,
    ch1: arguments.Choice,
    ch2: arguments.Choice = [1, 2, 3],
    d: arguments.Date = datetime(2021, 3, 7).date(),
    dt: arguments.DateTime = datetime(2021, 1, 12, 10, 21),
    a3: arguments.Int = 2,
    a4: arguments.Boolean = False,
    a5: arguments.Boolean = True
):
    '''
    stuff
    '''
    print(ch1)
    print(ch2)
    return datetime.now()

pr2 = Process(
    my_proc2,
    name='Custom name!'
)

a = App(
    processes=[pr, pr2],
    primary_colour='navy',
    secondary_colour='darkgray',
    accent_colour='lime',
    background_colour='black'
)

a.build()
a.launch()

HTML:

Preview
File itself

Example use case 2 (creating custom jinja template)

Python:

from gui_gen import App, Process, arguments
from datetime import datetime

class CustomRegex(arguments.Regex):
    pattern = r'[\d]*'
    template_html = 'CustomRegex.jinja2'  # path must be in the same location as class definition:
    # folder/
    #    my_code_with_class.py  # <- template_html = 'template.jinja2'
    #    template.jinja2
    # or
    # folder/
    #    my_code_with_class.py  # <- template_html = 'stuff/template.jinja2'
    #    stuff/
    #       template.jinja2

def my_proc2(
    text: CustomRegex,
    ch1: arguments.Choice = [1,2,3,4],
):
    '''
    stuff
    '''
    return datetime.now()

pr2 = Process(
    my_proc2,
    name='Custom name!'
)

a = App(
    processes=[pr2],
    primary_colour='navy',
    secondary_colour='darkgray',
    accent_colour='lime',
    background_colour='black'
)

a.build()
a.launch()

Jinja template:

{% extends "templates/generic.jinja2" %}
{% block input %}
<input
name={{argument.name}}
type="text"
placeholder="THIS IS CUSTOMIZATION FOR {{argument.__class__.__name__}}"
>
{% endblock %}

HTML:

Preview
File itself

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

GuiGen-1.2.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

GuiGen-1.2.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file GuiGen-1.2.0.tar.gz.

File metadata

  • Download URL: GuiGen-1.2.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for GuiGen-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ea8a20e6530c683f2d566c239ba2b85c0a49ded5efd8a49d48b04f39d438b240
MD5 79c0f07d6532ff01491a482312b41771
BLAKE2b-256 8375471a124f29272db19718f1ee31d158093bbe947907dc51e5a21097ad09da

See more details on using hashes here.

Provenance

The following attestation bundles were made for GuiGen-1.2.0.tar.gz:

Publisher: publish.yml on FilipM13/GuiGen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file GuiGen-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: GuiGen-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for GuiGen-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7887fb5a3fe536d57c803efcb82503cbc4bc17443d1d58bac83c41c5dcfb2799
MD5 55753e4488a97b84b70a09858c40a569
BLAKE2b-256 8539cdce85cfe200234bb092f9038a1a993ab432575f6c19c63ecdc0ad7138e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for GuiGen-1.2.0-py3-none-any.whl:

Publisher: publish.yml on FilipM13/GuiGen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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