Skip to content
Advertisement

Process finished with exit code -1073740791 (0xC0000409) error not opening a website

I am creating a desktop app using PyQt5 and QtDesginer. I have a login page connected to a database, and the user is asked to enter username and password. In the designer, I created a window that opens a certain link. The following code is running. But when inserting it into the second code it gives Process finished with exit code -1073740791 (0xC0000409).

JavaScript
JavaScript

Advertisement

Answer

The source of the problem mostly resides in the fact that only one and unique QApplication instance should ever exist for each process.

When you import Load_exam a QApplication instance already exists and is being executed, and that scipt will try to execute the last three lines (since there’s no if __name__ == '__main__' check), hence the crash.

Before providing the solution, consider the following two aspects:

  • import statements should always happen in the beginning of the scripts, as importing within the code (especially within a function) is usually unnecessary and often leads to unexpected problems; for common uses, the only accepted exception is to do that in the __name__ check;
  • editing of files generated by pyuic is considered bad practice and should never, ever be done unless you really know what you’re doing (and if you do know, you will probably not do it); those files are inteded to be exclusively imported, as explained in the official guidelines about using Designer;

With the above points in mind, recreate the ui for Ui_Form with pyuic (the following assumes the generated file is named loginForm.py), and create a new script like this:

JavaScript

Since you’re already using uic for the browser window, you can just skip the pyuic part, and just use the same on the login window as well:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement