FileBrowser使用python QtGUI显示来自不同目录的文件

时间:2013-02-21 06:13:56

标签: python python-2.7 file-browser qtgui

我有一些pdf文件的完整路径,这些文件位于不同的目录中,我想在一个窗口中显示这些文件,用户可以从中单击并打开它们和文档查看器。

由于我是python和QtGUI的新手,我无法弄清楚如何做到这一点。 Here is something我曾见过但无法弄清楚它是如何发生的。当我运行它,显示文件夹层次结构,但而不是我只想显示我有完整路径的文件。

提前致谢。

1 个答案:

答案 0 :(得分:1)

这段代码对我有用

import subprocess
import os
import sys
files = ['/home/test/kelvin/refresh.html','/home/test/kelvin/thread.html']
print list(enumerate(files))
no=raw_input("enter the file no\n")
no1 = int(no)
if sys.platform == 'linux2':
    subprocess.call(["xdg-open", files[no1]])
else
    os.startfile(files[no1])