settings.py 文件源码

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

项目:porcupine 作者: Akuli 项目源码 文件源码
def add_combobox(self, key, choices, text, *, case_sensitive=True):
        """Add a ``ttk.Combobox`` that sets an option to a string.

        The combobox will contain each string in *choices*.

        A `validator callback <Validating>`_ that ensures the value is
        in *choices* is also added. If *case_sensitive* is False,
        :meth:`str.casefold` is used when comparing the strings.
        """
        def validator(value):
            if case_sensitive:
                ok = (value in choices)
            else:
                ok = (value.casefold() in map(str.casefold, choices))
            if not ok:
                raise InvalidValue("%r is not a valid %r value"
                                   % (value, key))

        self.connect(key, validator)

        frame = self.add_frame(key)
        ttk.Label(frame, text=text).pack(side='left')
        ttk.Combobox(frame, values=choices,
                     textvariable=self.get_var(key)).pack(side='right')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号