3

I'm using gtk.Table in my python application. How can I remove a widget such a gtk.VBox, gtk.HBox or a gtk.Button that I attached in the table? I want to remove the widget in exactly position. Is there anyway to unattach a child widget from table? Such like:

table.attach(button,1,2,1,2)
table.unattach(button,1,2,1,2)
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
depzaivai
  • 33
  • 1
  • 5

2 Answers2

7
table.remove(button)

This works in general for GTK containers, such as hboxes and vboxes, not just tables.

dumbmatter
  • 9,351
  • 7
  • 41
  • 80
  • thanks. But i attach some buttons to table in a loop. Then i want to unattach just only 1 button, example the button at position (1,2,1,2). How can i do it ? – depzaivai Mar 30 '12 at 01:37
  • If you know you're going to be removing them later, the easiest way would be to just save the button variables and do as I did. If that's not possible, you can run `children = table.get_children()` and `children` will be a list of all the widgets you have in the table. – dumbmatter Mar 30 '12 at 15:50
  • Also, since you seem to be new here, Stack Overflow etiquette is that you're supposed to upvote helpful answers and then accept the most helpful answer. – dumbmatter Mar 30 '12 at 15:52
0

Not unattach.

table.remove(button,1,2,1,2) it works.

bhr
  • 9
  • 1
  • What version of Gtk allows you to remove by coordinates? This doesn't work. There is no such API that matches the above example. – Andy Mar 10 '18 at 18:18