[英]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.