Search code examples
pythonpyqt5tabula

tabula.exe path does not open in pyqt5


I Have specified the path to tabula.exe in pyqt5,when i run the code only the cmd flashes for a second and closes.I have tried the following

 def openUrl(self):
      url = QtCore.QUrl('C:/Users/DELL/Desktop/Tabula/tabula/tabula.exe')
       if not QtGui.QDesktopServices.openUrl(url):
           QtGui.QMessageBox.warning(self, 'Open Url', 'Could not open url')

Solution

  • When you use QDesktopServices::openUrl() it is to signal to the OS that it is necessary to open a file and that it is in charge of looking for the application that can do it. In your case it does not comply with that logic, so the solution is to use QProcess::startDetached():

    tabula_path = 'C:/Users/DELL/Desktop/Tabula/tabula/tabula.exe'
    if QtCore.QProcess.startDetached(tabula_path):
        QtWidgets.QMessageBox.information(self, 'Info', 'open a browser and go to http://localhost:8080')
    else:
        QtWidgets.QMessageBox.warning(self, 'Problem', 'Problem with tabula')