Advertisement
here2share

# Tk_fade_out_window.py

Aug 21st, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. # Tk_fade_out_window.py
  2.  
  3. import Tkinter as tk
  4.  
  5. class Example(tk.Frame):
  6.     def __init__(self, parent):
  7.         tk.Frame.__init__(self, parent)
  8.         b = tk.Button(self, text=" Click To Fade Away... ", command=self.quit)
  9.         b.pack()
  10.         self.parent = parent
  11.  
  12.     def quit(self):
  13.         self.fade_away()
  14.  
  15.     def fade_away(self):
  16.         alpha = self.parent.attributes("-alpha")
  17.         if alpha > 0:
  18.             alpha -= .1
  19.             self.parent.attributes("-alpha", alpha)
  20.             self.after(120, self.fade_away)
  21.         else:
  22.             self.parent.destroy()
  23.  
  24. if __name__ == "__main__":
  25.     root = tk.Tk()
  26.     Example(root).pack(fill="both", expand=True)
  27.     root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement