I'm running Feisty as well.

I launched python in two separate consoles and tried this:

1st console
----------------
import subprocess
subprocess.call('gedit --new-window window1',shell=True)

gedit launches with a blank file called window1.  The python shell is now
waiting for gedit to exit before it does anything else.

2nd console
---------------
import subprocess
subprocess.call('gedit --new-window window2',shell=True)

Another instance of gedit launches with a blank file called window2.  The
difference here is that the 2nd python shell instantly returns an exit code
of 0.

So you can definately launch multiple instances, but I'm not sure how you
would determine when the user was done editing the file after the first
instance of gedit has been launched.

Perhaps you could use this:

http://live.gnome.org/Gedit/PythonPluginHowTo

If you're going to stick with gedit.

On 6/22/07, Brian van den Broek <[EMAIL PROTECTED]> wrote:

Hi all,

I want to have a script launch an editor open to a particular file and
wait until that editor has closed before continuing. The aim is to
allow the user to make edits to the file, have to script know that the
edits are completed, and then make use of the newly saved file contents.

gedit is the default text editor on my ubuntu feisty system, so in the
first instance, I've tried to do this with gedit. The subprocess.call:

>>> subprocess.call("gedit somefilename", shell=True)

works just fine *provided* that no instance of gedit is running when I
invoke .call. However, if there is a gedit window up and running
(there usually is on my system ;-), the .call immediately returns exit
status 0:

>>> subprocess.Popen("ps -e|grep gedit", shell=True)
<subprocess.Popen object at 0xb7d06b4c>
>>> 26066 pts/2    00:00:01 gedit

>>> subprocess.call("gedit somefilename", shell=True)
0
>>> # The exit code is produced instantaneously

Interestingly, it works just fine if I use emacs in place of gedit,
irrespective of whether emacs was running before the subprocess.call
invocation or not. Is there any way to get it to work with gedit as it
is with emacs?

I am largely ignorant of the family of modules which subprocess was
designed to replace, and also of the details of processes on linux.
(In particular, I've no clue why gedit and emacs behave differently in
this respect.)

Thanks and best,

Brian vdB
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to