1

I'm trying to load a Qt5 file in a bundle on a Mac.

#!/usr/bin/env python
from PyQt5.QtWidgets import (QApplication,   QMainWindow)
from PyQt5 import  uic

import sys
import os

MainUI = os.path.dirname(os.path.realpath(__file__)) + "/data/MainUI.ui" 

Ui_MainWindow, QtBaseClass = uic.loadUiType(MainUI)
class MyForm(QMainWindow,Ui_MainWindow):    
    def __init__(self):     
        QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = MyForm()
    w.show()
    sys.exit(app.exec_())

This works fine in the commandline but when I bundle this with pyinstaller the program aborts because it can't find the file mainUI.ui. I found this solution but I can't get it working (resource_path function not found). I've made another and that worked fine but this one (a one file program) I can't get working.

Edit: I stopped trying to fix this and went for the multiple file solution: 1 file to startup and one for the PyQt functions. That works 100%.

Kayaquet
  • 21
  • 5

0 Answers0