ControlsGTK.py 文件源码

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

项目:pycam 作者: SebKuzminsky 项目源码 文件源码
def __init__(self, choices, change_handler=None):
        self.model = gtk.ListStore(GObject.TYPE_STRING)
        self._values = []
        for label, value in choices:
            self.model.append((label,))
            self._values.append(value)
        renderer = gtk.CellRendererText()
        self.control = gtk.ScrolledWindow()
        self.control.show()
        self._treeview = gtk.TreeView(self.model)
        self._treeview.show()
        self.control.add(self._treeview)
        self.control.set_shadow_type(gtk.ShadowType.ETCHED_OUT)
        self.control.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
        # Sadly there seems to be no way to adjust the size of the ScrolledWindow to its content.
        # The default size of the ScrolledWindow is too small (making it hard to select the model).
        self.control.set_size_request(200, -1)
        column = gtk.TreeViewColumn()
        column.pack_start(renderer, expand=False)
        column.set_attributes(renderer, text=0)
        self._treeview.append_column(column)
        self._treeview.set_headers_visible(False)
        self._selection = self._treeview.get_selection()
        self._selection.set_mode(gtk.SelectionMode.MULTIPLE)
        self.connect("changed", change_handler, self._selection)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号