Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Tkinter中重命名和调整图像大小_Python_Tkinter - Fatal编程技术网

Python 如何在Tkinter中重命名和调整图像大小

Python 如何在Tkinter中重命名和调整图像大小,python,tkinter,Python,Tkinter,目前,我在列表框中看到了文件路径。我只想在列表框中看到文件名。此外,我想调整所有的图像到一个标准大小。在过去的3个小时内尝试修复这两个部件。任何帮助都将不胜感激 tab4 = ttk.Frame(tabControl) tabControl.add(tab4, text="tab4") tabControl.pack(expand=5, fill='both') def showimg(e): n = lst.curselection() fname = l

目前,我在列表框中看到了文件路径。我只想在列表框中看到文件名。此外,我想调整所有的图像到一个标准大小。在过去的3个小时内尝试修复这两个部件。任何帮助都将不胜感激

tab4 = ttk.Frame(tabControl)
tabControl.add(tab4, text="tab4")
tabControl.pack(expand=5, fill='both')

def showimg(e):
    n = lst.curselection()
    fname = lst.get(n)
    img = tk.PhotoImage(file=fname)
    lab.config(image=img)
    lab.image = img
    print(fname)

lst = tk.Listbox(tab4)
lst.pack(side="left", expand=5)
namelist = [i for i in glob.glob("./fruit_images/*png")]
for fname in namelist:
    lst.insert(tk.ANCHOR, fname)
lst.bind("<<ListboxSelect>>", showimg)
img = tk.PhotoImage(file="./fruit_images/apple.png")
lab = tk.Label(tab4, text="hello", image=img)
lab.pack(side="left", anchor = "center")
tab4=ttk.Frame(tabControl)
tabControl.add(tab4,text=“tab4”)
tabControl.pack(expand=5,fill='both')
def显示(e):
n=lst.cursection()
fname=lst.get(n)
img=tk.PhotoImage(file=fname)
lab.config(image=img)
lab.image=img
打印(fname)
lst=tk.Listbox(表4)
第一组(侧=“左”,展开=5)
名称列表=[glob.glob中的i代表i(“./fruit\u images/*png”)]
对于名称列表中的fname:
第一个插件(tk.ANCHOR,fname)
lst.bind(“,showimg)
img=tk.PhotoImage(文件=“./fruit\u images/apple.png”)
lab=tk.Label(tab4,text=“hello”,image=img)
实验室包装(侧边=“左”,锚定=“中心”)

这些回答了您的问题吗?和