settings.py 文件源码

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

项目:porcupine 作者: Akuli 项目源码 文件源码
def add_spinbox(self, key, minimum, maximum, text):
        """
        Add a :class:`utils.Spinbox <porcupine.utils.Spinbox>` that sets
        an option to an integer.

        The *minimum* and *maximum* arguments are used as the bounds for
        the spinbox. A `validator callback <Validating>`_ that makes
        sure the value is between them is also added.

        Note that *minimum* and *maximum* are inclusive, so
        ``minimum=3, maximum=5`` means that 3, 4 and 5 are valid values.
        """
        def validator(value):
            if value < minimum:
                raise InvalidValue("%r is too small" % value)
            if value > maximum:
                raise InvalidValue("%r is too big" % value)

        self.connect(key, validator)

        frame = self.add_frame(key)
        ttk.Label(frame, text=text).pack(side='left')
        utils.Spinbox(frame, textvariable=self.get_var(key, tkinter.IntVar),
                      from_=minimum, to=maximum).pack(side='right')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号