Get current working directory from Vte (GTK Terminal Widget) in Python
문제
Hey, How can I get the current working directory of a VTE widget in Python? Thanks.
해결책
Borrowing from Mark, a slightly more elegant approach:
import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
workingDir = os.readlink('/proc/%s/cwd' % vPid)
다른 팁
This is a kludge, but the best way I can think of would be:
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()
제휴하지 않습니다 StackOverflow