view = Tk()
view.title("Title")
view.geometry('600x600')
view.attributes("-fullscreen",True)
def resize_image(event):
new_width = event.width
new_height = event.height
image = copy_of_image.resize((new_width, new_height))
photo = ImageTk.PhotoImage(image)
label.config(image = photo)
label.image = photo
image = Image.open('add.png')
copy_of_image = image.copy()
photo = ImageTk.PhotoImage(image)
label = ttk.Label(view, image = photo)
label.bind('<Configure>', resize_image)
label.pack(fill=BOTH, expand = YES)
command="pwd"
def changePicture():
print("I change picture")
image2 = Image.open('add.png')
copy_of_image = image2.copy()
photo = ImageTk.PhotoImage(image2)
label = ttk.Label(view, image = photo)
label.image=image2
label.pack()
它只能站立并且不能更改图片。我还有其他代码可用于“ add.png”图像。只是窗口静止不动,没有变化。谢谢您的帮助。
答案 0 :(得分:0)
更改行:
label.pack(fill=BOTH, expand = YES)
到
label.pack()