Creating a Simple User Interface for a Function

Terry Reedy tjreedy at udel.edu
Thu Jul 25 19:00:50 EDT 2013


On 7/25/2013 4:58 PM, CTSB01 wrote:

> 1) I decided to use Python 2.7, and I will be sure to specify this in
> all future threads.

Given that you are not using any libraries, let alone one that does not
run on Python 3, I strongly recommend using the latest version (3.3).

> 2) It is a list of positive integers.  In fact, it is always going to
> be a list of positive increasing integers.

Your example below starts with 0, which is not positive.
Perhaps you mean that all integers after a single leading 0 have to be 
positive and increasing.

If you run digits together, then the max int is 9. Do you intend this?

> 4) Yes, sorry that's what I meant (if I understood correctly).  I was
> told elsewhere that I might want to try using tkinter.

If users start the program at a command line, the core of an input 
function would be
   input = (raw)input('Enter digits: ')  # Include "raw" on 2.x
You would need a more elaborate prompt printed first, and input checking 
with the request repeated if the input does not pass the check.

It would be pretty simple to do the equivalent with a tkinter dialog box.

> I'd like to be
> able to run send a .exe file that the user can just open up and use
> with no further setup.

There are programs that will package your code with an interpreter. But 
do give people the option to get just the program without installing a 
duplicate interpreter.

> So on top of the user interface I would also it looks like need to
> determine how to make Python change a string 01112345 into a list so
> that it does that automatically when the user clicks 'run'.

 >>> list('01112345')
['0', '1', '1', '1', '2', '3', '4', '5']
 >>> '0,1,1,1,2,3,4,5'.split(',')
['0', '1', '1', '1', '2', '3', '4', '5']

> Would a shebang still be the right way to go?

On Linux, definitely, whether you have user enter on the command line or
in response to a prompt. On windows, it only helps with 3.3+.

-- 
Terry Jan Reedy




More information about the Python-list mailing list