So, thanks to the comments, I managed to find an answer. When setting attributes like -alpha
, some window managers delay applying them until the window is fully realized and shown. By adding root.update_idletasks()
before root.attributes("-alpha", 0.5)
my script now behaves like the terminal.
The updated code is now:
import tkinter as tk
if __name__ == "__main__":
root = tk.Tk()
root.geometry("400x400")
root.update_idletasks()
root.attributes("-alpha", 0.5)
root.mainloop()
Thanks for the help! I am leaving the answer here in case someone faces the same issue in the future.