我正在尝试创建一个exe"游戏";(更多的是概念验证),但当我这样做时,图像文件不会显示。:
parentDirectory = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
photo = tk.PhotoImage(file = os.path.join(parentDirectory, 'okokokokok1.1','imgs', 'spooky.PNG'),width=320,height=240)
老实说,我不明白出了什么问题,有人请帮帮thx;3
@furas解决了我的查询,谢谢。他们的评论:
您应该使用
os.path.dirname(os.path.abspath(__file__))
而不是os.getcwd()
,因为getcwd
提供的Current Working Directory
不必是Directory with Script