我是靠谱客的博主 自由老虎,这篇文章主要介绍python tkinter frame remove_如何删除tkinter Fram中的内容,现在分享给大家,希望可以做个参考。

from tkinter import *

from tkinter import filedialog

from PIL import Image, ImageTk

import cv2

def main():

root = Tk()

root.title("face")

w=root.winfo_screenwidth()

h=root.winfo_screenheight()

root.geometry("%dx%d" % (w, h))

def openimage(): #in this part I just want to keep just one picture in Frame

fname = filedialog.askopenfilename()

image = Image.open(fname)

(width, height)=image.size

if width>=height:

new_width=t1.winfo_width()

new_height=int(height*t1.winfo_width()/width)

image = image.resize((new_width, new_height), Image.ANTIALIAS)

else:

new_height=t1.winfo_height()

new_width=int(width*t1.winfo_height()/height)

image = image.resize((new_width, new_height), Image.ANTIALIAS)

render = ImageTk.PhotoImage(image)

img = Label(t1, image=render)

img.image = render

img.place(x=0, y=0)

def finish():

exit()

menubar = Menu(root)

root.config(menu=menubar)

menu1 = Menu(root)

menu1.add_command(label='openphoto', command=openimage)

menu1.add_command(label='get')

menu1.add_command(label='save')

menu2 = Menu(root)

menu2.add_command(label='read')

menu2.add_command(label='training')

menu3 = Menu(root)

menu3.add_command(label='openphotos')

menu3.add_command(label='dis')

menu4 = Menu(root)

menu4.add_command(label='quit', command=finish)

menubar.add_cascade(label="catch", menu=menu1)

menubar.add_cascade(label="train", menu=menu2)

menubar.add_cascade(label="distinguish", menu=menu3)

menubar.add_cascade(label="exit", menu=menu4)

t1=Frame(width=500,height=500, bg='gray')

t1.grid(padx=100, pady=100)

root.mainloop()

if __name__ =='__main__':

main()

我想清除框架中的内容,或者让前一张图片不显示在框架中,而我选择另一张图片。每次选择图片时,它与上次选择中使用的参数无关。所以每次选一张照片我都想清空一个相框。我试过很多方法。我不知道怎么清除它。在

最后

以上就是自由老虎最近收集整理的关于python tkinter frame remove_如何删除tkinter Fram中的内容的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部