【发布时间】:2019-08-03 22:15:48
【问题描述】:
我想使用 python 脚本打开一个文件,例如图像文件,通过这样做,当我选择在我的脚本中打开图像时,将文件名和位置传递给脚本。
在 Windows 10 中单击“在另一个程序中打开图像”
import tkinter as tk
filename = fileopen.name()
filelocation = fileopen.path()
window = tk.Tk()
imagepic = tk.PhotoImage(file=filelocation)
picture = tk.Label(window, image=imagepic)
window.mainloop()
我很确定有一个模块可以做到这一点,但我找不到它。
【问题讨论】:
-
是否有让用户选择图像的对话框?
-
我可以这样做,但我想让程序更加无缝
-
点击“在另一个程序中打开图像”这是一个上下文菜单(使用右键单击)吗?
标签: python-3.x tkinter file-handling