Packaged tkinter GUI using cx_freeze on MacOS results in a black GUI

女生的网名这么多〃 提交于 2021-02-08 05:57:46

问题


I am building a tkinter GUI for a friend in Python 3.8.3 on a Mac running macOS Catalina 10.15.2 and trying to freeze it using cx_freeze 6.1.

When I run the python application in my local environment the application works perfectly. (screenshot: tkinter GUI in local environment)

When I package the application using cx_freeze and try to run the Linux executable the tkinter window opens but it is all black and I cannot see anything in it (screenshot: tkinter GUI after packaging with cx_freeze)

My setup.py file is below, I run it using the command python3 setup.py build. Is there something I am missing in the file? Or does anyone know if it is a bug? I have tried running the executable directly in Terminal and there are no errors. Thank you!

from cx_Freeze import setup, Executable
import os.path
import sys

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(
    packages=["numpy", "os", "sympy", "sys", "tkinter"],
    includes=[],
    excludes=[],
    include_files=[],
    # replace_paths=[("*", "")],
    path=sys.path + ["lib"],
)

base = "Win32GUI" if sys.platform == "win32" else None

executables = [Executable("main.py", base=base)]
setup(
    name="NR Method Solver",
    version="1.0",
    description="A calculator to solves equation(s) with one or two unknown variables.",
    options=dict(build_exe=buildOptions),
    executables=executables,
)

This is my repo if anyone wants to view the whole code base https://github.com/gazelle51/nr-solver.

来源:https://stackoverflow.com/questions/61883644/packaged-tkinter-gui-using-cx-freeze-on-macos-results-in-a-black-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!