dialog_elements.py 文件源码

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

项目:Enrich2 作者: FowlerLab 项目源码 文件源码
def validate(self):
        if not self.enabled:
            return True
        elif len(self.value.get()) == 0:
            if not self.optional:
                tkMessageBox.showwarning("",
                                         "{} not specified.".format(self.text))
                return False
            else:
                return True
        else:
            if os.path.exists(self.value.get()):
                if self.extensions is not None:
                    if any(self.value.get().lower().endswith(x) for x in
                           self.extensions):
                        return True
                    else:
                        tkMessageBox.showwarning("", "Invalid file extension "
                                                 "for {}.".format(self.text))
                        return False
                else:  # no extension restriction
                    return True
            else:
                tkMessageBox.showwarning("", "{} file does not exist."
                                         "".format(self.text))
                return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号