python - Having trouble with Tkinter transparency -


I'm having trouble fading a top-level widget in the checker. For some reason the widget is not faded, it will appear in the taskbar, but only after clicking on the button that runs this command twice (it should not be in the taskbar).

Code responsible for these issues

  alpha = 0.0 w1.attributes ("- alpha", alpha) w1.wm_geometry ("+" + str (x) + "+" + Str (M) while 1.0 & gt; Alpha: alpha = alpha + 0.01 w1.attributes ("- alpha", alpha) sleep (0.005)  

This is Python 2.6 on Windows 7.

The problem is that your code does not allow windows to underline itself again the sleep program Is prevented so that the event loop does not enter, and this is an event loop, so that the window can be drawn.

Instead of sleeping, take advantage of the event loop and update the properties of each N millisecond unless you get the desired alpha transparency.

Here's an example that works on Mac. I think it also works on windows too.

  Imported Techniker as a vaccine category as App: def __init __ (self): self.root = tk.Tk () self.count = 0b = tk.Button (Text = " Create window ", command = self.create_window) b.pack () self.root.mainloop () def create_window (self): self.count + = 1 t = FadeToplevel (self.root) t.wm_title (" window% s "% Self.count) t.fade_in () class FadeToplevel (vaccines local): An overlay widget with the ability to fade in '' '' Ã ¢ __int __ (self, * elgs, ** quorz): vaccine. Local .__ init __ (self, * args, ** kwargs) self.attributes ("- alpha", 0.0) def fade_in (self): alpha = self.attributes ("- alpha") alpha = min (alpha + 01, 1.0) Self. Features ("- alpha", alpha) if alpha & lt; 1.0: Self. After (10, self.fed_in) if __name__ == "__main__": app = app ()  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -