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
评论列表
文章目录