2024-01-09

MacOs Tkinter - App terminating 'Invalid parameter not satisfying: aString != nil'

When im launching my app via CLI, it works without issue

./org_chart.app/Contents/MacOS/org_chart

however when I launch via double click I met with the error

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

I used py2app to build the app. Im not sure where to begin debugging this, if someone could point me in the right direction?

Thanks for your help!

here's the full code for the small app

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()

Also now my app is so small its still crashing im thinking it could be something in the setup file too so ive added that code below

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'],
)


No comments:

Post a Comment