我遇到了一个问题,我做了一个小项目,它可以使用 tkinter 和 OS 模块通过按钮关闭、重新启动、休眠、睡眠电脑,但是当尝试使用 pyinstaller 将 .py 转换为 .exe 时,它显示输出为成功完成,但当单击执行的可执行文件时,它说该应用程序不可执行。
下面我附上了我的代码。
from tkinter import *
import os
from os import system as sys
from tkinter import messagebox as msg
screen = Tk()
screen.title("System - Properties")
screen.geometry("500x500")
screen.resizable(False,False)
screen.configure(background="powderblue")
screen.iconbitmap("LOGO.ico")
canvas1 = Canvas(screen,height=100,width=480,bg="red",bd=5,relief="groove").place(x = 3,y = 0)
Header = Label(canvas1,text="SYSTEM CONTROL",fg="black",bg="tomato",
font=("Courier New",30,"bold")).place(x = 85,y = 30)
canvas2 = Canvas(screen,height=260,width=470,bg="teal",bd=10,relief="sunken").place(x = 3,y = 120)
# button function starts
def shutdown():
sys("shutdown /s /t 1")
def restart():
sys("shutdown /r /t 1")
def logoff():
sys("shutdown /l /t 1")
def hibernate():
sys("shutdown /h /t 1")
def help():
content = "This app helps to perform some simple actions \nJust click the button according to your use. \n\n\tDO NOT PLAY WITH THIS"
msg.showinfo("HELP",content)
def about():
content= "Author : John Arthur\nDate : 19/07/2021 \nProgramming Language : Python"
msg.showinfo("ABOUT",content)
# button starts
shutdown = Button(canvas2,text="SHUTDOWN",bd = 2,relief="sunken",command=shutdown,bg="black",fg="white",
font=("Bell MT",15,"italic")).place(x = 40,y=175)
restart = Button(canvas2,text="RESTART",bd = 2,relief="sunken",command=restart,bg="black",fg="white",
font=("Bell MT",15,"italic")).place(x = 190,y=175)
logoff = Button(canvas2,text="LOG-OFF",bd = 2,relief="sunken",command=logoff,bg="black",fg="white",
font=("Bell MT",15,"italic")).place(x = 340,y = 175)
hibernate = Button(canvas2,text="HIBERNATE",bd = 2,relief="sunken",command=hibernate,bg="black",fg="white",
font=("Bell MT",15,"italic")).place(x = 40,y=250)
help = Button(canvas2,text="HELP",bd = 2,relief="sunken",command=help,bg="black",fg="white",width=9,
font=("Bell MT",15,"italic")).place(x = 190,y=250)
about = Button(canvas2,text="ABOUT",bd = 2,relief="sunken",command=about,bg="black",fg="white",
font=("Bell MT",15,"italic")).place(x = 340,y=250)
# function button over
canvas3 = Canvas(screen,height=70,width=480,bg="black",bd=5,relief="groove").place(x=3,y=410)
# control button starts
quit = Button(canvas3,text="exit",bd = 2,relief="sunken",command=exit,bg="orange",fg="black",width=15,
font=("Arial",20,"bold")).place(x = 110,y=425)
# control button ends
screen.mainloop()
有人能帮我解决这个问题吗。