天蓬老师2017-04-18 10:12:06
I am also using pyqt recently, 233~
I don’t know what your file refers to, but if your file and your py file are in the same directory, then this will be easy to handle.
The code below is just an outline
First you get the file name of the node you clicked
fileName = self.currentRow().text()
# 不知道tree是不是这样,反正QListWidget获取当前节点就是currentRow()
Get the absolute path, and then concatenate it with the file name to get the absolute path of the file
import os
# 获取当前文件的绝对路径,也就是你的py文件的当前绝对路径
abDir = os.path.abspath(os.path.join(os.path.dirname(__file__))).replace('\','/')
fileDir = abDir + fileName
If it can solve the problem, please adopt it~~~