2

I am making a small application that will help me keep track of projects and the due dates of the projects. One of the things I would like to add is the ability to open the main project folder in the file explorer. I have the QLabel link working by setting the text to

(label.setText('<a href='+ProjectFolder+'>Open Project Folder</a>')

and I have

label.setOpenExternalLinks(True)

But when I click on it nothing happens and I'm getting errors in the terminal window. They are all something like

ShellExecute 'z:%5C16904' failed (error 2)

I'm assuming this is because of \ and spaces that are in the link, but I'm not sure how to fix them. I have tried '\\' but doesn't seem to help. Any advice would be much apricated. Thank you for your time

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
laxer
  • 720
  • 11
  • 41

1 Answers1

1

First of all use forward slash /.

You can try to use %20 C:/Program%20Files" for whitespaces but it didn't work for me even though I see proper whitespace instead of %5C in console output log. If you really need to use whitespaces in folders check this

link

QLabel("<a href={}>Open Project Folder</a>".format("`C:/Progra~1/needed"`))
  • Thank you so much! replacing all the white space with `%20` and `\` with `/` seems to have done the trick. Also from the comment on the main question, I added `file:///` and it is now working correctly. Now it looks like `('label.setText(Open Project Folder')` – laxer May 17 '17 at 14:25