Question

Hé, comment puis-je obtenir le répertoire fonctionnel actuel d'un widget de TV-Python? Merci.

Était-ce utile?

La solution

Emprunt à Mark, une approche légèrement plus élégante:

import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
workingDir = os.readlink('/proc/%s/cwd' % vPid)

Autres conseils

C'est une kludge, mais la meilleure façon à laquelle je peux penser serait:

import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
# make a system call to pwdx to get working director
sIn, sOut = os.popen2("pwdx " + vPid)
workingDir = sOut.read()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top