Issue
I'm currently using QT designer to show a picture on my loading screen.
This is because for some reason its not showing my picture, when it registers in my IDE that the filepath is correct as seen here:
The only time the picture actually shows in my loading GUI is when I use the FULL file path which is: C:\Users\myalt\OneDrive\Desktop\GUINEW\assets\PostmonkeyLogo.png
But of course, this is not viable when this software will be used on many different computer with different file paths.
self.label.setPixmap(QPixmap(u"assets/PostmonkeyLogo.png")) ## image file path to show
Solution
The problem is that the file path is relative to where the console was opened and the python.exe command is executed. It is better to build the full path using the information as the path of the .py:
import os.path
# ...
CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(CURRENT_DIRECTORY, "assets/PostmonkeyLogo.png")
self.label.setPixmap(QPixmap(filename))
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.