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)