I wrote a password generator and built a GUI for it using the PyQt5 designer. The script calls the .ui in its initiator and both are in the same folder.
def __init__(self, parent=None):
super().__init__(parent)
self.ui = uic.loadUi('Generator.ui', self)
However, after converting both to an .exe file via PyInstaller, after extracting the .exe file from its dist folder and executing it, a console pops up and closes immediately, without showing the GUI.
How can I fix this without manually adding the .ui code to the Generator.py script??
Thank you
I made this an answer show I could show an example. Use the pyuic tool to convert the .ui file to a .py file. The .py file this creates will have a class in it that is the name of the widget built in Qt Designer. Import and subclass this class into the GUI class that you are creating.
from designer_file import Ui_Gui # Designer file is the converted .ui file and Ui_Gui is the ui class it created
class GUIWindow(QtWidgets.QWidget, Ui_Gui):
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self) # This is necessary to setup the ui when using this method
# Code here...