Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_fade_out_window.py
- import Tkinter as tk
- class Example(tk.Frame):
- def __init__(self, parent):
- tk.Frame.__init__(self, parent)
- b = tk.Button(self, text=" Click To Fade Away... ", command=self.quit)
- b.pack()
- self.parent = parent
- def quit(self):
- self.fade_away()
- def fade_away(self):
- alpha = self.parent.attributes("-alpha")
- if alpha > 0:
- alpha -= .1
- self.parent.attributes("-alpha", alpha)
- self.after(120, self.fade_away)
- else:
- self.parent.destroy()
- if __name__ == "__main__":
- root = tk.Tk()
- Example(root).pack(fill="both", expand=True)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement