[Tkinter-discuss] How to eliminate flickers when swapping frames?
Nam Nguyen
namnguyen at google.com
Tue Mar 27 15:57:39 EDT 2018
A simple reprod code:
import tkinter as tk
from tkinter import font
root = tk.Tk()
root.minsize(1280, 800)
root.bind('<Escape>', lambda _: root.quit())
my_font = font.Font(root, 'Sans 128 bold')
f_1 = tk.Frame(root)
tk.Button(f_1, text='Frame 1', font=my_font).pack(
expand=True, fill=tk.BOTH)
f_2 = tk.Frame(root)
tk.Button(f_2, text='Frame 2'[::-1], font=my_font).pack(
expand=True, fill=tk.BOTH)
f_1.pack(expand=True, fill=tk.BOTH)
current = f_1
def flip():
global current
current.pack_forget()
if current is f_1:
current = f_2
else:
current = f_1
current.pack(expand=True, fill=tk.BOTH)
root.after(1000, flip)
root.after(1000, flip)
root.mainloop()
Nam
On Tue, Mar 27, 2018 at 8:29 AM, Nam Nguyen <namnguyen at google.com> wrote:
> Hi list,
>
> I have several ttk.Frames belonging to the same parent (master, but I try
> not to use that word) that are swapped in and out depending on some
> external event.
>
> What I observe so far is there is some flickering every time a frame is
> swapped out and another swapped in. I have tried using both place and pack
> geometry managers.
>
> Do you have any tip/trick to eliminate this flickering?
>
> Thanks!
> Nam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20180327/bc27309b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4849 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20180327/bc27309b/attachment.bin>
More information about the Tkinter-discuss
mailing list