简体   繁体   English

为什么我的 py2app 不工作,启动错误

[英]Why My py2app is not working , launch error

I built my app, :我构建了我的应用程序:


import os, shutil
import tkinter as tk
from tkinter import *
#Ca ouvre le fichier et prend la derniere et avant derniere ligne
with open('Secrets.txt', 'r') as f:
    last_line = f.readlines()[-1]
#Ca fait la fenetre
window = tk.Tk()
window.title("Rentre un secret")
window.geometry('1100x60')
#Ton secret
lbl = Label(window, text="Ton secret:")
lbl.grid(column=0, row=0)
txt = Entry(window,width=100)
txt.grid(column=1, row=0)
txt.pack
#ecrire dans le fichier txt ton secret
def enreg():
    "Enregistrer ton secret"
    obfichier = open('Secrets.txt','a')
    if txt.get():
        obfichier.write(txt.get()+"\n")
    obfichier.close()
    
bou2 = Button(window, text = 'Enregistrer', command = enreg)
bou2.grid(row = 1, column = 0)
#L'autre Secret
log = Label(window, text="L'ancien secret: " + last_line)
log.grid(column=1, row=1)
directorya = txt.get()

but when I do./dist/TonSecret.app/Contents/MacOS/TonSecret, it does nothing.. and when I click on the app icon it tells me: Launch error Launch error See the py2app website for debugging launch issues can u help me但是当我这样做时./dist/TonSecret.app/Contents/MacOS/TonSecret,它什么都不做..当我点击应用程序图标时,它告诉我:启动错误启动错误查看py2app网站调试启动问题你能帮忙吗我

py2app issues aside, this code doesn't do anything because you're never entering the tkinter event loop. py2app问题放在一边,此代码不执行任何操作,因为您永远不会进入tkinter事件循环。 Add this line to the end of your code and your code will do something:将此行添加到代码的末尾,您的代码将执行以下操作:

window.mainloop()

If you want help in understanding why what you get when applying py2app doesn't work, you'll need to provide more information about just what you're doing to build your executable.如果您想了解为什么在应用py2app时得到的结果不起作用,您需要提供有关构建可执行文件的操作的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM