문제

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top