0
import tkinter
from tkinter import ttk
from PIL import Image, ImageTk

def decrypte():
    style = ttk.Style()
    style.theme_use("alt")

    style.configure("green.Horizontal.TProgressbar", foreground='green', background='green')
    decrypte_window = tkinter.Toplevel(root)
    decrypte_window.title("Decrypt your files")
    decrypte_window.geometry("900x700")
    area_decrypte =  tkinter.Frame(decrypte_window, bg="black", width=900, height=400)
    area_decrypte.pack()
    area_decrypte.pack_propagate(False)
    img_hdd = ImageTk.PhotoImage(Image.open('hdd.png'))
    tkinter.Label(area_decrypte, image=img_hdd, width=100, height=100).pack()

def block_all():
    global root
    global background
    global label
    decrypt = tkinter.Button(background, text="Decrypt", width=14, height=2, command=decrypte, bg="#0078FF", foreground="#fff").pack(side="right", anchor="se", pady=30, padx=60)
    root.mainloop()


root = tkinter.Tk()
root.geometry("1100x900")
background = None
block_all()

我想在顶层显示一个图像,但我注意到我的图像没有显示,路径是正确的。我意识到问题出在顶层,如何使用 tkinter 在顶层显示图像?

4

0 回答 0