On 23.11.2016 08:02, Andreas Paeffgen wrote:
> On 2016-11-22 13:20:58 +0000, Wolfgang Langner said:
> 
>> Hi,
>>
>> you are using the new release 5.0.
>>
>> I tried it also to test compatibility to older releases.
>>
>> On thing I noticed is in the 5.0 release something like:
>>
>> if __name__ == "__main__":
>>   main()
>>
>> is no longer possible in your provided startup script.
>>
>> In the 5.0 the startup script is only imported.
>>
>> Simply execution your main in the script at top level like:
>>
>> main()
>>
>> solved it.
>>
>> If you are under Windows and only double click/execute the executable nothing
>> will happen and you also see no error.
>> This does look like the executable does not start.
>>
>> Regards,
>>
>> Wolfgang
> 
> 
> Hi Wolfgang,
> could you clarify what you mean?
> In the main Python PyQt5 app, if i delete if __name__ == "__main__":, 
> the whole app does not work any more. Not from the source not from the 
> frozen app. But if i start the frozen app, i get QT-Error message. 
> Logical, because the app does not start any more.
> 
> Maybe i have to change something in the setup file?
> 

In setup.py for cx_Freeze you provide something like:

Executable("myscript.py", ...)

In this file myscript.py at top level your "main" function must be called.

A guard with:

if __name__ == "__main__":
  main()

does no longer work and is no longer executed by cx_Freeze.

This is because the file "myscript.py" is only imported.
For imports only top level code is executed.

Example content of myscript.py:

from myapp import main

main()




Regards,

Wolfgang



------------------------------------------------------------------------------
_______________________________________________
cx-freeze-users mailing list
cx-freeze-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users

Reply via email to