MacOs Tkinter - 应用程序终止“无效参数不满足:aString!= nil”

问题描述 投票:0回答:1

当我通过 CLI 启动我的应用程序时,它可以正常工作

./org_chart.app/Contents/MacOS/org_chart

但是,当我通过双击启动时,我遇到了错误

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: aString != nil'

我使用 py2app 来构建应用程序。我不确定从哪里开始调试这个,如果有人能指出我正确的方向吗?

感谢您的帮助!

这是小应用程序的完整代码

import os, shutil
import tkinter as tk
from tkinter import filedialog, messagebox, Tk, Canvas, Entry, Text, Button, PhotoImage
from tkinter import font as tkFont

def build_org_chart():

    print("im making a chart")
  
    return 'Done chart created!'

if __name__ == "__main__":
    window = Tk()
    window.title("Org Chart Spreadsheet Generator")

    # Variables to store file paths
    window.geometry("1012x506")
    window.configure(bg = "#00403D")

    # Define the font properties
    my_font = tkFont.Font(family="Montserrat SemiBold", size=16, weight="normal")

    canvas = Canvas(
        window,
        bg = "#00403D",
        height = 506,
        width = 1012,
        bd = 0,
        highlightthickness = 0,
        relief = "ridge"
    )

    canvas.place(x = 0, y = 0)
    canvas.create_rectangle(
        308.0,
        0.0,
        1012.0,
        506.0,
        fill="#FFFFFF",
        outline="")

    canvas.create_text(
        320.0,
        18.0,
        anchor="nw",
        text="Org Chart",
        fill="#000000",
        font=("Montserrat Bold", 64 * -1)
    )

    window.resizable(False, False)
    window.mainloop()

现在我的应用程序太小了,它仍然崩溃,我认为它也可能是安装文件中的某些内容,所以我在下面添加了该代码

import os
from setuptools import setup

def list_files(directory):
    base_path = os.path.abspath(directory)
    paths = []
    for root, directories, filenames in os.walk(base_path):
        for filename in filenames:
            # Exclude .DS_Store files if you are on macOS
            if filename != '.DS_Store':
                paths.append(os.path.join(root, filename))
    return paths

# Your assets folder
assets_folder = 'assets'

# Listing all files in the assets folder
assets_files = list_files(assets_folder)

APP = ['org_chart_min.py']
DATA_FILES = [('assets', assets_files)]
OPTIONS = {
    'argv_emulation': True,

    'packages': ['pandas', 'openpyxl','xlsxwriter'],
        'plist': {
        'CFBundleName': '_org_chart',
        'CFBundleDisplayName': ' Org Chart',
        'CFBundleGetInfoString': "Create a spreadsheet that populates our Lucid org chart template",
        'CFBundleIdentifier': 'com.yourdomain.orgchart',
        'CFBundleVersion': '0.1',
        'CFBundleShortVersionString': '0.1',
        'NSRequiresAquaSystemAppearance': True
    },
    'iconfile': 'org_chart.icns',
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)
python macos tkinter py2app
1个回答
0
投票

在终端上运行它

rm ~/Library/Containers/com.apple.Safari/Data/Library/Saved\ Application\ State/com.apple.Safari.savedState/windows.plist

这将重置 Safari 保存的状态,这很可能是这里的问题。

© www.soinside.com 2019 - 2024. All rights reserved.