如何删除编辑TKinter小部件Python

问题描述:

我试图为一个无用的挂人游戏设置简单的框架工作,图像被命名为每个阶段的失败6系列。 S0是开始和S6,是最后阶段。如何删除编辑TKinter小部件Python

我试图找出如何推翻照片。

from tkinter import * 
from PIL import ImageTk, Image 

root = Tk() 
i=0 

frameLeft = Frame(root) 
frameRight = Frame(root) 
frameRight.pack(side=RIGHT) 
frameLeft.pack(side=LEFT) 

#frame Left 

#function Declaration 
entry1 = Entry(frameLeft) 
entry1.pack() 
def updatePhoto(): 
     i = entry1.get() 
     img = ImageTk.PhotoImage(Image.open("S" + i + ".gif")) 
     imgPanel = Label(frameRight, image = img) 
     imgPanel.pack(side=BOTTOM, fill=BOTH, expand=YES) 
labelInstruction = Label(frameLeft, text=entry1.get()) 
labelInstruction.pack() 
submitButton = Button(frameLeft, text="Submit", command=updatePhoto) 
submitButton.pack() 

#frame Right 

img = ImageTk.PhotoImage(Image.open("S" + str(i) + ".gif")) 
imgPanel = Label(frameRight, image = img) 
imgPanel.pack(side=BOTTOM, fill=BOTH, expand=YES) 

root.mainloop() 

相反,这些线:

imgPanel = Label(frameRight, image = img) 
imgPanel.pack(side=BOTTOM, fill=BOTH, expand=YES) 

我能够使用这些

imgPanel.configure(image=img) 
imgPanel.image = img 

我也改变了顺序左侧和右侧使权是第一位的,因为它是一个脚本语言并需要声明。