laxer
laxer

Reputation: 760

PYQT QLabel link to open folder on computer

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

Upvotes: 2

Views: 3030

Answers (1)

AlexanderFokin
AlexanderFokin

Reputation: 61

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"`))

Upvotes: 1

Related Questions