如何使Tkinter窗口中的背景透明?

时间:2019-09-14 11:02:31

标签: python tkinter

如何使窗口背景透明,但图像仍然可见?

这是我的代码;

from tkinter import Tk, Label, Button, Canvas
from PIL import ImageTk, Image

class MyFirstGUI:
    def __init__(self, master):
        self.canvas = Canvas(master, width = 300, height = 300)
        self.canvas.pack()
        self.image = ImageTk.PhotoImage(Image.open("Sprites/ph1.png"))
        self.canvas.create_image(150, 150, image=self.image)
        self.master = master
        master.title("A simple GUI")

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()

    def greet(self):
        print("Greetings!")

root = Tk()
root.geometry("+1630+775")
root.overrideredirect(1)
my_gui = MyFirstGUI(root)
root.mainloop()

0 个答案:

没有答案