This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tk could not refresh auto in mac os
Type: behavior Stage: resolved
Components: macOS, Tkinter Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asper, epaine, ned.deily, ronaldoussoren, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2021-12-17 14:27 by asper, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (9)
msg408780 - (view) Author: asper (asper) Date: 2021-12-17 14:27
from tkinter import *
from tkinter import ttk


def change():
    global flag
    if flag == 1:
        namelbl.grid_remove()
        namelbl2.grid(column=0, row=0)
        entry2.grid(column=1, row=0, sticky=(W, E))
        flag = 2
    elif flag == 2:
        namelbl2.grid_remove()
        namelbl.grid()
        flag = 1


root = Tk()
root.columnconfigure(1, weight=1)

namelbl = ttk.Label(root, text="Name")
namelbl2 = ttk.Label(root, text="Name2")
entry1 = ttk.Entry(root)
entry2 = ttk.Entry(root)

ok = ttk.Button(root, text="change", command=change)
ok.grid(column=1, row=1)
namelbl.grid(column=0, row=0)
entry1.grid(column=1, row=0, sticky=(W, E))
flag = 1

root.mainloop()

I run the script in mac os 12.1, use python3.10 download from python.org. when the main window show, I change it's size, and press the   "change" button, the script change the label'text from "Name" to "Name2".When press the button again, the label'text from "Name2" to "Name". but the label cannot refresh the text, it show nothing. when I move the mouse, the text showed immediately. 
The script run normally on windows system.
I use the grid_remove() and grid() to switch frame.
msg408785 - (view) Author: asper (asper) Date: 2021-12-17 14:36
sorry, I update mac os to 12.1, when press "change" button, this simple sample can refresh the label'text, but have a delay. when I use grid_remove() and grid() to switch two frame, it cannot refresh auto, must move the mouse can refresh.
msg408811 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-12-17 19:21
IDLE is neither the Python it is written it, nor the tkinter module it depends on.  For this tracker, this is at most a tkinter on macOS 12 issue.  But I suspect that it is an issue of the 3rd party tcl/tk on the new macOS version.  There have been others.  Perhaps someone else can test on earlier macOS.  (I verified that the code works as intended on Win 10 with Tk 8.6.12.)

I am not sure of your intention in half-closing this issue.  But, does adding 'root.update_idletasks()' to the end of 'change' make any difference?
msg408834 - (view) Author: asper (asper) Date: 2021-12-18 06:42
Thank you for your reply. The phenomenon is still exist on mac os, when I add 'root.update_idletasks()'. The version of tk on mac os is 8.5.9, the version of tk is show 8.6.12 from the enviroment of python3.10.
Now, I use lower() and lift() to switch two frame in tkinter, it works well.
msg408835 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-12-18 06:55
The macOS system tk, 8.5.9, is over a decade old and buggy.  python.org python now always uses the recent 8.6 version included with the installer.
msg409104 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2021-12-23 20:20
The script seems to work fine for me, python 3.10.1 on macOS 12.1. I used the python.org installer.

Did you install Python from source or using the installer? What's the output of ``python3 -m test.pythoninfo``, in particular the lines related to Tcl/Tk at the end?

For example:

...
time.tzname: ('CET', 'CEST')
tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.12
zlib.ZLIB_RUNTIME_VERSION: 1.2.11
...
msg409121 - (view) Author: asper (asper) Date: 2021-12-24 04:29
tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.11
zlib.ZLIB_RUNTIME_VERSION: 1.2.11
zlib.ZLIB_VERSION: 1.2.11
On my system, it shows like that.
It works well if not change the widnow's size of program, but once change the window's size manually, press "change" button, it shows a little delay.
msg409179 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2021-12-26 08:34
I don't know why it doesn't work for you. The version of Tk looks recent enough.

As I mentioned before I don't see this problem using the script in your initial message, it works fine both with and without changing the size of the window. 

You could try installing Python 3.10.1, which should get you the exact some binary and Tcl/Tk version as I'm using. That might fix the problem.

Btw. I'm on an M1 MacBook, although that shouldn't be relevant here.
msg409247 - (view) Author: asper (asper) Date: 2021-12-28 03:26
It looks like that Python3.10.1 has solved this question.
Now use grid_remove() and grid() to switch two widgets smoother than before on my mac system. 
Ronald Oussoren, Thank you for your time and advice, I could close this issue.
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90275
2021-12-28 03:26:46aspersetstatus: open -> closed
resolution: fixed
messages: + msg409247

stage: resolved
2021-12-26 08:34:18ronaldoussorensetmessages: + msg409179
2021-12-24 04:29:36aspersetmessages: + msg409121
2021-12-23 20:20:38ronaldoussorensetmessages: + msg409104
2021-12-18 06:55:49terry.reedysetmessages: + msg408835
2021-12-18 06:42:55aspersetmessages: + msg408834
2021-12-17 19:21:22terry.reedysetstatus: pending -> open

nosy: + ned.deily, epaine, serhiy.storchaka, ronaldoussoren
messages: + msg408811

assignee: terry.reedy ->
components: + macOS, Tkinter, - IDLE
2021-12-17 14:36:48aspersetstatus: open -> pending

messages: + msg408785
2021-12-17 14:27:10aspercreate