2

I am new to Python, currently working on my first app, which is command line driven, but somewhat complex so that I would like to add a GUI front-end.

So, basically, I just want to design a GUI to accept input, rather than passing it on the command line.

Generally, we are taking of text input fields, with perhaps radio buttons, check-boxes & drop-down combo/list boxes - nothing too fancy.

The only slight problem is that I might want to have multiple possible text inputs depending on some other items on the form. Let's imagine that I want to add one - or more - people, each with a name & email address.

I could just guess at the max number of users and place that many empty inputs on the form, but what if my guess is wrong, besides which, it will look ugly if we only want to add one.

Better would be to have one input and have a plus sign to add more, so a GUI builder that allows that automatically is a big bonus. Otherwise I would have to handle a click on the plus sign at run-time then create a new input and shuffle the other controls down the form :-(

I hope that I have described this clearly. This is likely to be a one off, with no further Python in my future, so something with little learning curve is desirable.

2

If you can cleanly express your program on the command line, then Gooey should be able to cover all of your use cases. It also has the bonus of creating the GUI automatically so you don't have to design it yourself.

The only point I'm unsure on is what you mean by multiple text inputs; meaning, I'm not sure how this looks on the command line. Or how your conditional logic works. So it may not be perfect for your script.

  • Thanks, Michael, I was aware of Gooey, but unsure myself. I am not sure if I can even specify multiple users, each with name & email, e.g. myprpgrm.py --user john --email john@doe.com --user jane --email jane@doe.com. I need to dig into argparse for that. I may end up asking the user to specify in an input file, like a windows .INI, although a GUI would be preferable. – Mawg Jan 12 '15 at 12:58
  • 1
    Ah I see. Yeah, I'm not sure how that would translate since I've never written anything that used command line args that way. Most of my scripts are far simpler. Hopefully someone else has a better solution since input files aren't ideal in a GUI situation. – Michael Cheng Jan 12 '15 at 13:11
  • I am still waiting on the result of programmers.stackexchange.com/questions/269816/… If possible, you get the answer :-) – Mawg Jan 12 '15 at 16:07
1

Personally I am a big fan of wxPython but as a slightly out of field suggestion have you considered having an iPython interface?

wxPython comes complete with a test/demo suite that covers all of your options while iPython has the interact library that provides any that are missing from the base interface.

1

PySimpleGUI is a recently released wrapper for tkinter that was designed specifically for these kinds of GUI tasks. The idea is to be able to create a custom GUI in 5 or 10 lines of code.

pip install PySimpleGUI

This Tutorial published on OpenSource.com talked specifically about adding using PySimpleGUI to add a GUI onto a command line application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.