我正在尝试使用bdist_mac在Mac上使用cx-freeze打包Python Tkinter应用程序。一切都可以编译,但是实际的GUI却显示为黑屏(即使窗口小部件仍然存在,因为我可以单击它们)。我已经附加了setup.py和一个示例Tkinter应用。
编辑:在软件包中添加了“ os”,并从包括中删除了tkinter-仍然没有进展。
不确定这是否表示什么,但是我尝试了bdist_mac和bdist_dmg -均未创建a.dmg或.app文件。
setup.py:
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tk8.6')
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages=['_sysconfigdata_m_darwin_darwin', 'cairocffi', 'cairosvg', 'tkinter', 'os'], includes=[], excludes=[],
include_files=['/Users/celinaperalta/Documents/NYLTesting/rally-exports/', os.path.join(PYTHON_INSTALL_DIR, 'libtcl8.6.dylib'), os.path.join(PYTHON_INSTALL_DIR, 'libtk8.6.dylib')])
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('Test.py', base=base)
]
setup(name='RallyReportTool',
version = '1.0',
description = 'For use within New York Life CRM team',
options = dict(build_exe = buildOptions),
executables = executables)
Test.py:
from tkinter import *
def main():
window = Tk()
window.title("Welcome to Test app")
lbl = Label(window, text="Hello")
lbl.grid(column=0, row=0)
window.mainloop()
if __name__ == "__main__":
main()