tkinter program compiles with cx_Freeze but program will not launch

后端 未结 3 1188
[愿得一人]
[愿得一人] 2020-11-29 12:23

I\'m trying to create an executable following this tutorial

https://github.com/anthony-tuininga/cx_Freeze/tree/master/cx_Freeze/samples/Tkinter

After some t

3条回答
  •  感情败类
    2020-11-29 13:16

    I have a working setup.py here. Maybe you can try and see if it works after using the same config. Basically sometimes after compiling, the tk and tcl dll/packages are missing and so you need to include them during the setup.

    import sys, os
    from cx_Freeze import setup, Executable
    
    includes = []
    
    include_files = [r"C:\Users\user\AppData\Local\Programs\Python\Python36-32\DLLs\tcl86t.dll",
                     r"C:\Users\user\AppData\Local\Programs\Python\Python36-32\DLLs\tk86t.dll"]
    
    base = 'Win32GUI' if sys.platform == 'win32' else None
    
    os.environ['TCL_LIBRARY'] = r'C:\Users\user\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
    os.environ['TK_LIBRARY'] = r'C:\Users\user\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'
    
    setup(name="simple_Tkinter",
          version="0.1",
          options={"build_exe":{"includes":[],"include_files":include_files}},
          description="Sample cx_Freeze Tkinter script",
          executables=[Executable("SimpleTkApp.py",base=base)])
    

提交回复
热议问题