I would like to open a specific folder (not a file) in the file manager by pushing a button in a Tkinter frame. Does anyone know the function?
-
3This question is a programming question (“how to interact with the UI of another program from within a Python program”) which should be asked elsewhere as it is not specific to the Raspberry Pi.– Phil B.Dec 15, 2019 at 13:21
1 Answer
For asynch
:
import os
myfolder="/home/pi/Desktop"
def onMyButtonClick():
os.system("pcmanfm \"%s\"" % myfolder)
For asynch or ̶s̶y̶n̶c̶h̶
use python subprocess Popen
:
import subprocess
myfolder="/home/pi/Desktop"
def onMyButtonClick():
p = subprocess.Popen(["pcmanfm", "%s" % myfolder], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
p.communicate()
-
1