开发者

Python/Tkinter: pack equivalent of grid_remove(), eg. pack_remove()?

开发者 https://www.devze.com 2023-01-29 22:53 出处:网络
Is there a pack equivalent of the grid_remove() method where a widget\'s original pack() settings are restored on a re-pack()?

Is there a pack equivalent of the grid_remove() method where a widget's original pack() settings are restored on a re-pack()?

Use case: When I show a packed widget that has been h开发者_高级运维idden via pack_forget(), I would like to have the widget re-packed with its original pack settings when I issue the widget.pack() show request.


No, there is no equivalent. There is only pack_forget which doesn't remember where the widget was when you restore it. If I need this sort of feature I just use the grid geometry manager.


from tkinter import *

root = Tk()

b = Button(root, text="Delete me", command=lambda: b.grid_remove())
b.grid(row=0,column=0)

root.mainloop()

grid_remove works
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号