When distributing a GUI program created with Tkinter, I think it is better to pass it as ** Installer ** rather than ** exe executable file **. cx_Freeze had that feature, so I tried it.
This time, the program to be installed is here. (OS: Windows 10, 64bit)
[Python] Show multiple windows in Tkinter
file name:multi_winews_tkinter.py
Since I am using Anaconda, I will install it with conda instead of pip.
conda install -c conda-forge cx_freeze
Create setup.py in the folder where the Python program (* file name: multi_winews_tkinter.py *) is located.
For how to write setup.py, I referred to this page. The sample setup.py for various purposes is easy to use, so please refer to it. (Example: GUI creation with PyQT) https://github.com/anthony-tuininga/cx_Freeze/tree/master/cx_Freeze/samples
setup.py
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
executables = [
Executable('multi_windows_tkinter.py', base=base)
]
setup(name='simple_Tkinter',
version='0.2',
description='Sample cx_Freeze Tkinter script',
executables=executables
)
In the terminal, execute the following command.
python setup.py bdist_msi
When that happens, an Installer file (msi file) is formed. The capacity of the Installer this time was 11MB.
Execute the above Installer file on a PC that does not have a Python environment installed. The following screen will be displayed and the installation will start.
As a result of installation, it worked without problems. Finally, if you want to uninstall, you can easily uninstall it with the Windows Control Panel, just like any other Windows Program. It's convenient.
cx_Freeze Good. It works fast and the size of the generated file is small, so I'm satisfied.
Recommended Posts