def update_widgets(self):
widgets = list(self._widgets)
widgets.sort(key=lambda item: item.weight)
# remove all widgets from the table
for child in self._table.get_children():
self._table.remove(child)
# add the current controls
for index, widget in enumerate(widgets):
if hasattr(widget.widget, "get_label"):
# checkbox
widget.widget.set_label(widget.label)
self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL,
yoptions=gtk.Align.FILL)
elif not widget.label:
self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL,
yoptions=gtk.Align.FILL)
else:
# spinbutton, combobox, ...
label = gtk.Label("%s:" % widget.label)
label.set_alignment(0.0, 0.5)
self._table.attach(label, 0, 1, index, index + 1, xoptions=gtk.Align.FILL,
yoptions=gtk.Align.FILL)
self._table.attach(widget.widget, 1, 2, index, index + 1, xoptions=gtk.Align.FILL,
yoptions=gtk.Align.FILL)
self._update_widgets_visibility()
评论列表
文章目录