how to implement saving?

  python, tkinter

I need to make the button save the path to its application. That is, I bind, say, a shortcut to a button, everything works, but if I restart, everything needs to be done again. Please tell me how to implement saving?

my code:

import tkinter.filedialog as tfd
import tkinter as tk
import os


window = tk.Tk()
window.title("Мой Открыватель")
window.geometry("600x400")
window.resizable(False, False)

file_name = ""


def open():
    global file_name
    if file_name == "":
        file_name = tfd.askopenfilename()
        os.startfile(file_name)
    else:
        os.startfile(file_name)
    if btn1["text"] == "":
        btn1["text"] = file_name


btn1 =  tk.Button(window, text="", command=open)
btn1.place(x = 20, y = 25)


window.mainloop()

Source: Python Questions

LEAVE A COMMENT