我的问题是如何使用我稍后会选择askopenfilename()的文件,例如将它放在画布上? 我该怎么做而不是"?" at" Im =?" ? 谢谢 ! 对不起,我是初学者
import tkinter as tk
from tkinter import *
from tkinter.filedialog import *
root=tk.Tk()
root.geometry('1000x690')
root.title("Baccalauréat ISN 2017")
# # #
def Open_Image():
askopenfilename()
# # #
B13= Button(root, text='Open Image', height=5, width= 25, command = askopenfilename)
B13.grid(row=1, column=5, sticky= W + E)
Im = ?
# # #
Nim = Im.resize((int((Im.width*514)/Im.height), 514)) #maxsize =(821, 514) ---> size of the canvas 821-length; 514 -height
nshow = ImageTk.PhotoImage(Nim)
Can = tk.Canvas(root, background = 'blue')
Can.grid(row = 1, column = 0, rowspan = 6, columnspan = 5, sticky = W + E + N + S)
Cim = Can.create_image(0, 0, anchor = NW, image = nshow) # "0, 0" space between the picture and the borders
# # #
mainloop()