我正在做一个战舰游戏,下面有一个函数,用来创建一个以爆炸图像为背景的新按钮。我正在使用Mac&;python 3.7
global redraw_gameboard
global Player
global AI_player
script_dir = os.path.dirname(__file__)
rel_path = "explode.png"
image = ImageTk.PhotoImage(file=os.path.join(script_dir, rel_path))
new_button = Button(redraw_gameboard,
height = 2,
width = 4,
command= already_shot,
image=image)
new_button.grid(row = row, column = column)
这就是即将出现的情况:
我不知道你期望什么,因为我不知道“explode.png”图像是什么样子。此外,在询问有关stackoverflow的问题时,请始终尝试发布minimal reproducible example
然而,据我所知,问题可能是因为图像比按钮大,而且被裁剪了。然后,按钮中仅显示图像的左上部分
建议的解决办法: (如果尚未安装枕头包,则需要安装它)
当然,您需要对您的程序进行一些更改,例如使用您的小部件架构
相关问题 更多 >
编程相关推荐