1

Currently I can open a folder by using

dirPath = os.path.dirname(os.path.abspath(self.oVidPath))
QDesktopServices.openUrl(QUrl.fromLocalFile(dirPath))

I want to know if there is anyway I can open folder with a file preselected?

I am okay if it only works on linux systems (nautilus is preferred)

edit : This application is only going be for linux systems

Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98

1 Answers1

3

For windows

import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.Qt import QProcess

if __name__ == '__main__':
    app = QApplication(sys.argv)
    command = "explorer /e, /select, c:\\windows\\regedit.exe"
    process = QProcess()
    process.start(command)
    sys.exit(app.exec_())

For Linux

import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.Qt import QProcess

if __name__ == '__main__':
    app = QApplication(sys.argv)
    command = "nautilus /var/log/dpkg.log"
    process = QProcess()
    process.start(command)
    sys.exit(app.exec_())

FYI https://askubuntu.com/a/82717/249546

Community
  • 1
  • 1
suiwenfeng
  • 1,865
  • 1
  • 25
  • 32