ControlsGTK.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pycam 作者: SebKuzminsky 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号