Message408780
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. |
|
Date |
User |
Action |
Args |
2021-12-17 14:27:10 | asper | set | recipients:
+ asper, terry.reedy |
2021-12-17 14:27:10 | asper | set | messageid: <1639751230.51.0.11843295078.issue46117@roundup.psfhosted.org> |
2021-12-17 14:27:10 | asper | link | issue46117 messages |
2021-12-17 14:27:10 | asper | create | |
|