Reputation: 91
I try to make a splash screen with a png. I use Python 3.7.4 64-bit, under macOS 10.14.4 and Visual Code 1.33.1
With root.overrideredirect(True) no windows are displayed. With root.overrideredirect(False) the png is correctly displayed but the top window border is visible.
import tkinter as tk
root = tk.Tk()
# Hide the root window drag bar and close button
root.overrideredirect(True)
# Make the root window always on top
root.wm_attributes('-topmost', True)
# Turn off the window shadow
root.wm_attributes('-transparent', True)
# Set the root window background color to a transparent color
root.config(bg='systemTransparent')
root.geometry('+300+300')
# Store the PhotoImage to prevent early garbage collection
root.image = tk.PhotoImage(file='./local/pics/splash.png')
# Display the image on a label
label = tk.Label(root, image=root.image)
# Set the label background color to a transparent color
label.config(bg='systemTransparent')
label.pack()
root.mainloop()
Thanks for your help
Upvotes: 1
Views: 1859
Reputation: 1
root.wm_attributes('-transparent', True)
makes the whole window transparent, regardless of elements inside.
I tested it in my Linux machine with root.wm_attributes('-alpha', 0)
and it made the whole window transparent, not just the shadows. (-alpha is -transparent alternative in Linux)
Try to remove it, keep the root.wm_overrideredirect(True)
, and use a different method to remove the window shadow.
Other methods might be system specific.
Upvotes: 0
Reputation: 577
This will hide the title bar
and fixates your window to top always:
root.attributes('-type', 'dock')
If you don't need it at the top:
root.attributes('-type', 'splash')
This will hide the title bar
If this can be improved please comment.
Upvotes: 1