WIndows Mysteriously Launch After Exiting a Frozen Application

7 views
Skip to first unread message

Chip Shand

unread,
Jul 27, 2020, 3:44:31 AM7/27/20
to PyInstaller

After exiting a frozen application, one of the applications windows pops up right after the main window closes.

 

I have a frozen application with four script files created in Python 3.8 on a Windows 10 platform.  I created a frozen distribution folder using a spec file.  The main script is the first one in the Analysis list.  The other two script files in the Analysis list generated from using Qt Designer to create window layouts and then converting the .ui files to .py files.  One of these is the layout of a QDialog window and the other is the layout of a QMainWIndow layout.  At the bottom of these two window layout scripts are if __name__ == “__main__” blocks of code.   Here is the one for the QDialog window:

 

if __name__ == "__main__":
   
import sys
    app
= QtWidgets.QApplication(sys.argv)
    dialogConfig
= QtWidgets.QDialog()
    ui
= Ui_dialogConfig()
    ui
.setupUi(dialogConfig)
    dialogConfig
.show()
    sys
.exit(app.exec_())


 

After executing and closing the frozen application, the QDialog window unexpectedly launched and the console (when I build with console=True) remains active.  I deleted the code block (above), refroze, executed, and closed.  This time the QMainWindow unexpectedly launched and the console, again, did not close.  I deleted the block of code in the QMainWindow layout script, refroze, executed, and closed.  This time everything appeared to close as expected.

 

It appears that the frozen baseline somehow thinks that the two layout scripts are main windows and executes them after the main application closes.. 

 

I have a similar frozen baseline with similar script files generated y Qt Designer that does not exhibit this mysterious behavior.  Nor was I able to reproduce the issue with a minimalized script.

 

Am I doing something incorrect, or is there an issue?  Here is my spec file:

 

block_cipher = None
a
= Analysis(['VTMv008.py','VTMConfig.py','VTMLayout.py'],
             pathex
=['c:\\Users\\slalo\\Documents\\VTMBuild'],
             binaries
=[],
             datas
=[('VTMIcon.ico','.'),
                   
('VTMLicense.txt','.'),
                   
('VTMManual.htm','.'),
                   
('VTMManual_files','VTMManual_files')],
             hiddenimports
=[],
             hookspath
=[],
             runtime_hooks
=[],
             excludes
=[],
             win_no_prefer_redirects
=False,
             win_private_assemblies
=False,
             cipher
=block_cipher,
             noarchive
=False)
pyz
= PYZ(a.pure, a.zipped_data,
             cipher
=block_cipher)
exe
= EXE(pyz,
          a
.scripts,
         
[],
          exclude_binaries
=True,
          name
='VTMv008',
          debug
=False,
          bootloader_ignore_signals
=False,
          strip
=False,
          upx
=True,
          console
=True)
coll
= COLLECT(exe,
               a
.binaries,
               a
.zipfiles,
               a
.datas,
               strip
=False,
               upx
=True,
               upx_exclude
=[],
               name
='VTMv008')


bwoodsend

unread,
Jul 27, 2020, 7:03:39 AM7/27/20
to PyInstaller

This line in your spec implies that PyInstaller should run each of these scripts as main scripts one after the other.

 a = Analysis(['VTMv008.py','VTMConfig.py','VTMLayout.py'],`

It should only contain your top level script. If this top level script imports the other 2 then these will be included automatically but not as main scripts so their if __name__ == "__main__": blocks wont execute.

Reply all
Reply to author
Forward
0 new messages