[Tkinter-discuss] How to eliminate flickers when swapping frames?

Nam Nguyen namnguyen at google.com
Tue Mar 27 16:27:06 EDT 2018


I'm running i3-wm on Debian and this code tends to flicks more when I have
my mouse over the buttons.
Nam

On Tue, Mar 27, 2018 at 1:17 PM, Bryan Oakley <bryan.oakley at gmail.com>
wrote:

> I don't see any flicker when I run that.
>
> On Tue, Mar 27, 2018 at 2:57 PM, Nam Nguyen via Tkinter-discuss <
> tkinter-discuss at python.org> wrote:
>
>> 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
>>>
>>
>>
>> _______________________________________________
>> Tkinter-discuss mailing list
>> Tkinter-discuss at python.org
>> https://mail.python.org/mailman/listinfo/tkinter-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20180327/58611cd0/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/58611cd0/attachment.bin>


More information about the Tkinter-discuss mailing list