filedialog.askopenfilename()
filedialog.asksaveasfilename()
# !/user/bin/env Python3
# -*- coding:utf-8 -*-
import tkinter as tk
from tkinter import filedialog, dialog
import os
from PIL import Image
window = tk.Tk()
window.title('窗口')
window.geometry('500x500')
file_path = ''
file_text = ''
save_list=[]
def open_file():
global file_path
global file_text
file_path = filedialog.askopenfilename()
image = Image.open(file_path)
image.show()
save_list.append(image)
def save_file(x):
print(x)
global file_path
x.show
file_path = filedialog.asksaveasfilename()
x.save(file_path)
print('保存文件', file_path)
bt1 = tk.Button(window, text='打开文件', width=15, height=2, command=open_file)
bt1.pack()
bt2 = tk.Button(window, text='保存文件', width=15, height=2, command=lambda :save_file(save_list[0]))
bt2.pack()
window.mainloop()