79279709

Date: 2024-12-13 22:25:51
Score: 1
Natty:
Report link

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.

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Nathan Gavenski