[英]Open file with pyQt
有一个按钮。
单击它时,应使用默认文本编辑器打开文件C:\\file.txt
(就像双击一样)。
在pyQt中有可能吗? 按下按钮 - >文件打开。
所有我可以谷歌只是对话,但我不需要它们。
file = 'C:\file.txt'
widget.connect(button, QtCore.SIGNAL('clicked()'), ????)
怎么做?
def openFile(file):
if sys.platform == 'linux2':
subprocess.call(["xdg-open", file])
else:
os.startfile(file)
并编辑您的第二行:
widget.connect(button, QtCore.SIGNAL('clicked()'), openFile(file))
从如何使用标准应用程序打开文件复制打开文件的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.