简体   繁体   English

Python Glade-重置网格

[英]Python Glade - Reset a Grid

He everyone! 他大家! I'am creating a Grid-Layout in Glade and adding some Labels and buttons. 我正在Glade中创建一个网格布局,并添加了一些标签和按钮。 THe User can add more rows by a little pop-up menue. 用户可以通过一个小的弹出菜单添加更多行。 After that the data is reloading and all labels and buttons will re-write on the grid. 之后,将重新加载数据,所有标签和按钮将重新写入网格。 It works fine but the problem is, that the labels, which are still on the grid, are still there so the text will over-laying. 它可以正常工作,但问题是仍在网格上的标签仍然存在,因此文本会重叠。 Now i want to remove all existing labels from the grid to start re-writing with a empty grid. 现在,我想从网格中删除所有现有标签,以开始用一个空网格重写。 Set-Parent, remove or something like that doesnt works - main problem is that a dont get some data back from the grid...some ideas? Set-Parent,remove之类的方法不起作用-主要问题是不要从网格中获取一些数据...一些想法? THX! 谢谢!

To remove all the child widgets: 删除所有子窗口小部件:

for child in grid.get_children():
    grid.remove(child)

To remove only the labels, add an extra if statement in there. 要仅删除标签,请在其中添加额外的if语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM