Skip to content

Pyinstaller with "--onefile" tag does not add the data for button icons #8563

Discussion options

You must be logged in to vote

I didn't understand this __file__ aproach, i find a diferent one that works for me.

def resource_path(relative_path):
    """ Get the absolute path to the resource, works for dev and for PyInstaller """
    try:
        base_path = sys._MEIPASS
    except AttributeError:
        base_path = path.abspath(".")

    return path.join(base_path, relative_path)
    
......
.......
class Ui_MainWindow(object):
         ...
        def setupUi(self, MainWindow):
               self.heading_btn.setIcon(QIcon(loadSvgIcon(resource_path('icons/bx-heading.svg'))))

Thanks for help me.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Ernesto-Alves67
Comment options

@bwoodsend
Comment options

@Ernesto-Alves67
Comment options

Answer selected by Ernesto-Alves67
@bwoodsend
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants