繁体   English   中英

使 Python 可执行到应用程序 mac os catalina

[英]make Python executable into app mac os catalina

我试图将我的 python 放入一个名为“folder.app”的文件夹中,然后放入“Contents”然后放入“MacOs”,但每当我尝试打开它时,它什么都不做。 这是 Python 代码:

    #!/usr/bin/env python3
    import tkinter as tk
    from PIL import Image, ImageTk
    import time
    import os
    import ast
    #other stuff
    f = open("/Users/mimmo/ssh_login_system/login_info.txt", "r")
    contents = f.read()
    f.close()
    users = ast.literal_eval(contents)
    #variables
    stuff = ""
    newlist = []
    login = ""
    inp = ("| => ")

    rw = tk.Tk()
    rw.title("Login")
    rw.configure(bg="grey14")
    rw.geometry("500x200")

    def login(self):
        username = e1.get()
        password = e2.get()
        if username in users:
            if password == users[username]:
                rw.destroy()
                print ("\nlogin successful!\n")
                os.system("python3 connect")

    a = tk.Label(rw, text="Username:", fg='white', bg='grey14').grid(row=0)
    b = tk.Label(rw, text="Password:", fg='white', bg='grey14').grid(row=1)

    e1 = tk.Entry(rw)
    e2 = tk.Entry(rw, show="*")
    e2.bind("", login)

    e1.grid(row=0, column=1)
    e2.grid(row=1, column=1)

    rw.mainloop()

仅将 python 可执行文件放入具有 .app 扩展名的文件夹中不会使您的 python 代码成为本机应用程序。 看看可以将您的 python 代码构建到本机应用程序中的库 -有很多甚至更多关于如何使用它们的教程,谷歌周围!

对于 macOS,只有应用程序py2app可以工作,但对于其他跨平台选项,请参阅此现有答案

暂无
暂无

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

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