[Tutor] How can I open and use gnome-terminal from a Python script?

Alan Gauld alan.gauld at btinternet.com
Sat Jul 12 20:36:39 CEST 2014


On 12/07/14 16:34, Jim Byrnes wrote:

> I guess because I don't have the depth of knowledge to know any better.
> I wanted to automate a tedious process using Python.  I was working with
> a Python3 version of breezypythongui on a Python2.7 system. So I would
> open a terminal, cd to the correct directory and run source
> bin/activate, which would leave me with an open window.

OK, Now imagine you were doing this in (bash) shell - I think you
are familiar with shell scripts? You wouldn't try to make the shell
script open a second terminal and then try to inject commands
into that terminal? You would just run the cd and source commands in the 
shell script within the terminal session you were already
using, right?

Python is just another scripting tool. You use it the same way. You run 
the script from a terminal so you don't need to open another one, just 
use the one you are in.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list