According to the python docs, you want to use
Popen.communicate(input=None)
http://docs.python.org/2/library/subprocess.html#popen-objects
I would recommend that you edit your command from python before sending it to another process. For example, display a window with the default command and allow the user to edit (or cancel) it before executing it. Also, "gnome-terminal" is probably overkill for this, "/bin/bash" should be sufficient.
If that doesn't work for you, you could also try this. (depending on what you are actually running from the terminal) Since you mentioned users could edit the command, it would be a good idea to validate the input before running.
command = ['ls','-l']
output = subprocess.check_output( command )
print( output )
You can use this for files:
zenity --file-selection
and this for folders:
zenity --file-selection --directory
for usage, run:
zenity --help-general
zenity --help-file-selection
Generally it matches the current theme (for GTK window managers anyway), on my machine with a modded version of Zukitwo 3.8 it looks like this:
One way of using it is like this:
echo "you selected $(zenity --file-selection)"
Which would result in you selected /path/to/file
.
You can also use options to set an appropriate title, and the directory it starts in - With your rsync use case, for example:
zenity --file-selection --directory --title="Choose rsync source directory" --filename=$HOME/Desktop/
For files, you can also specify a filetype to select - e.g:
zenity --file-selection --file-filter='PDF files (pdf) | *.pdf' --title="Select a PDF file"
NOTE: You can also use YAD, a fork of Zenity that has loads more features.
sudo add-apt-repository ppa:webupd8team/y-ppa-manager
sudo apt-get update
sudo apt-get install yad
Source
For the most part you can use it the same way - for the file browser:
yad --file-selection
and for the help page:
yad --help-all
Though at the time (around version 26?), it had not been updated to match the new GTK 3.14+ interface (zenity had) - it has more features, but check compatibility (based on documentation it should work on GTK+ >= 2.16.0
Best Answer
There are different Terminal emulators (the windows) and different shells (the thing that does the work) and they can be configured or changed. Maybe you'll like the Zsh-shell more than the Bash which is default.
Terminal are made for Text In- and output. i don't think there is a need of a GUI. There are GUI-applications, which can be used as alternative to shell commands
There is possibility for Copy&Paste in Terminal emulators and many shells offer auto-complete with the TAB-key
many shells offer auto-complete with the TAB-key
most commands offer a simple help with
command --help
. For more information there are manpages:man command
You can open the help section in a different window or look it up on the internet with your browser
I know the shell is hard at the beginning, but there are much more possibilities than with most GUI-applications. If you like to do more with the shell, there are wikis who explain step for step how to use it