import os# 假设 script_directory 是你的脚本所在的目录
script_directory = os.path.dirname(os.path.abspath(__file__))# 使用 os.path.join 来构建相对路径
relative_path_to_image = os.path.join(script_directory, '合并/figure_pic2.png')# 现在你可以使用这个相对路径来加载图片了
self.custom_button_img2 = tk.PhotoImage(file=relative_path_to_image)
self.custom_button2 = ttk.Button(self, image=self.custom_button_img2, command=export_pdf)
self.custom_button2.pack(side=tk.LEFT)