Re: How to eliminate flickers when swapping frames?

Nam Nguyen via Tkinter-discuss <[email protected]> Tue, 27 Mar 2018 12:57:39 -0700
Newsgroups gmane.comp.python.tkinter
Message-ID <CA+YNSmWZ47+bf2ZoFr2LxMMX-PYc4QtQLHCrTf7aYe5rSty4Ag@mail.gmail.com>
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 <[email protected]> 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
>

_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss
smime.p7s (application/pkcs7-signature, 4.7 KB) - not displayed