Skip to content
/ pypagui Public

Automatic Python Parameter GUI Generator

License

Notifications You must be signed in to change notification settings

ptoews/pypagui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Automatic Python Parameter GUI Generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages