我是初學者,使用 tkinter 制作了我的第一個 GUI 計算器。我想將我的 py 文件轉換為 exe 文件。我嘗試使用pyinstaller,auto-py-to-exe但是當文件準備好并運行時,它顯示 Windows 錯誤框Cannot run Script main,我的文件名是 main .import getpassfrom os import mkdirimport tkinter,os,timefrom functools import partialfrom tkinter import PhotoImagefrom tkinter.constants import SELclass Calculator(tkinter.Tk): '''This class creates calculator using tkinter module''' def __init__(self): super().__init__() # Changing height and width of window self.geometry('279x316') self.resizable(False,False) self.title('Calculator') image=PhotoImage('download.ico') self.iconbitmap(image) # Creating tkinter varible to store what user has entered self.__store_value=tkinter.StringVar() self.__store_value.set('') #Creating entry widget for input self.__input_user=tkinter.Entry(self,font='lucidia 20 bold',textvariable=self.__store_value) self.__input_user.pack(fill='x') self.bind('<Return>',partial(self.click,'=')) # This Buttons will be ther in calculator self._button_dict={"C":"C","(":"(",")":")","/":"/", "9":9,"8":8,"7":7,"*":"*", "6":6,"5":5,"4":4,"+":"+", "3":3,"2":2,"1":1,"-":"-", "His":"His","0":0,".":".","=":"="} def create_button(self,row=5,column=4): '''Creates button in the window,button_dict contains name of each button and an argument to be given to click function when pressed,no of rows in calculator and no. of columns''' self.__main_frame=tkinter.Frame(self) self.__main_frame.pack(fill='both') k=0 for i in range(row): for r in range(column): 我在上傳 ico 圖片時出錯,所以你可以在https://github.com/01TanmayDaga/Calculator找到圖片請幫我??!
1 回答

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
有一個非常簡單的解決方案,確保所有外部文件(圖標、圖像等)都放在包含可執行文件 (.exe) 的文件夾中。
在 的情況下PyInstaller
,.exe 被放入一個名為 的文件夾中dist
,只需將您在程序中使用的所有外部文件移動到該文件夾中,它應該可以工作。
希望它有所幫助,干杯!
添加回答
舉報
0/150
提交
取消