1

This question needs hints from the python community on how to create simple, flexible user interfaces for python scripts. The idea is simple: a script creats plots based on parameters from a config file. Instead of editing the config file and re-running the script over and over again, the user should be able to:

  1. display the content of the config file in a nice App interface,
  2. play with the editable parameter fields, and
  3. run the script, which ideally live-updates the plots and saves the output files.

I know that there are many tools out there, and I tried some of them, but I figured four main limitations so far:

  • Window-based Qt-like librarys like PySimpleGUI are not flexible: window widths and element positions are hard-coded and don't work work for an arbitrary number of elements that should be auto-generated from the config file. (In addition, these GUIs are often not "modern" and display-responsive.)
  • Web-based tools (which I would prefer most) often run on localhost and therefore do not allow for file-system i/o and other more complex system operations beyond the web folder.
  • Developer-savy tools like Jupyter Notebooks are too complex for a simple users,
  • My patience to try out each and every single python-App generator (-;

What could be a good solution to these requirements?
Can you provide an example App with your favourite tool for the following minimal example:

config.cfg:

[files]
file_input  = data.csv
file_output = output.pdf
[params]
param1 = 42

data.csv:

id,value
0,42
1,23
2,314
3,37

Script.py (read config, read data, do calculations, save plots):

import configparser
import pandas
import matplotlib.pyplot as plt
import matplotlib.backends.backend_pdf

config = configparser.ConfigParser()
_ = config.read('config.cfg')
    
data = pandas.read_csv(config['files']['file_input'])
data['result'] = data['value'] * float(config['params']['param1'])
print('Calculated: %.1f' % data.result.mean())

with matplotlib.backends.backend_pdf.PdfPages(config['files']['file_output']) as fig:
    plt.figure(figsize=(6, 6))
    plt.plot(data.id, data.result)
    fig.savefig()
    plt.close()
    
print('Done.')

Exemplary illustration how a potential GUI could look like: enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.