0

I am adding a GUI to a command line python program using Tkinter. So far, I have the existing program running as a subprocess in a text widget on my GUI. The usage for the original file is:

Python [SCRIPT] -i [PATH TO FILE]

I wanted to know if it is possible to change the "-i" argument so that I can replace it with an input from the Tkinter Open file dialog. If so, a nudge in the right direction would be very much appreciated! Thanks in advance.

1
  • What do you mean by "subprocess in a text widget"? You can't put a subprocess in a widget. Did you mean that the output of the subprocess is being inserted in the text widget? Commented Mar 15, 2013 at 14:43

1 Answer 1

0

The Open File dialog returns a string, like this one: C:/path/filename.cmd. Use the following line of code to retrieve it:

str = filedialog.askopenfilename()

You weren't clear enough on how exactly are you implementing this command. If it's implemented as a string of text, e.g. your program is set to write an exe file, all you have to do is insert the program in the string, like this:

text = "Python [SCRIPT] " + str + " [PATH TO FILE]"

Otherwise, make the Python code write another Python code with a string including this input and run it.

Sign up to request clarification or add additional context in comments.

Comments

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.