Giter Club home page Giter Club logo

pypagui's Introduction

pypagui

Automatic Python Parameter GUI Generator

Do you have scripts with parameters you change frequently? Want to do some quick runs with different parameters, without having to hardcode them each time, cluttering your Git changes?

Then pypagui is just for you!

How to use

Simply wrap any function in your code that takes the parameters of interest with the pypagui decorator:

import matplotlib.pyplot as plt
import numpy as np

import pypagui  # Add this


@pypagui.wrap_function  # Add this
def plot_sin(amplitude: float = 1, phase_shift: float = 0):
    t = np.arange(0.0, 2 * np.pi, 0.01)
    plt.plot(t, amplitude * np.sin(t + phase_shift))
    plt.show()


if __name__ == '__main__':
    plot_sin(2)

When running this code, a GUI window will open, with an edit widget for each function parameter. Each value is initialized from the function call arguments, or the default values otherwise:

img.png

Clicking the Run button executes the wrapped function with the entered parameter values. By default, the window will stay open, so that after finishing execution, the next run can be configured and run immediately. In some sense, especially for more complex code, the GUI can act as a checkpoint.

Check the examples directory for more examples.

Installation

Tested with Python 3.10 (should run at least with >= 3.7)

pip install git+https://github.com/ptoews/pypagui

Development

TODO

  • Handle wrapping of GUI code, e.g. matplotlib show() requiring to be run in main thread
    • run in separate process (as an option?)
  • Support additional data types (incl. casting)
    • Filepaths
  • Add widget to choose parameter value type
    • Allows handling typing.Union and typing.Optional (i.e. choosing None)
  • Improve widgets layout
  • Allow configuration of wrap_function() decorator
  • Handle positional-only and var-positional arguments
  • Tests
  • Implement alternative (simpler) GUI backend (PySimpleGUI?)
  • Module wrapping
    • Multirun
    • use type annotations

Ideas

  • Save and load configs
    • Load settings from last time
  • Show console output for a fully integrated solution

pypagui's People

Contributors

ptoews avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.