简体   繁体   中英

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM