本文整理汇总了Python中General.validate_Float方法的典型用法代码示例。如果您正苦于以下问题:Python General.validate_Float方法的具体用法?Python General.validate_Float怎么用?Python General.validate_Float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类General
的用法示例。
在下文中一共展示了General.validate_Float方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Validate_Field
# 需要导入模块: import General [as 别名]
# 或者: from General import validate_Float [as 别名]
def Validate_Field(self, *args, **kwargs):
input = kwargs.pop('input')
var = kwargs.pop('var')
min = kwargs.pop('min')
max = kwargs.pop('max')
ndec = kwargs.pop('ndec')
tag = kwargs.pop('tag')
_type = kwargs.pop('_type')
rv = -1
if _type == float:
if type(min) != float:
try:
min = float(min.get())
except:
min = 0
if type(max) != float:
try:
max = float(max.get())
except:
max = 0
rv = General.validate_Float(var.get(), min, max, ndec)
elif _type == int:
if type(min) != int:
try:
min = int(min.get())
except ValueError:
min = 0
if type(max) != int:
try:
max = int(max.get())
except ValueError:
max = 100
rv = General.validate_Integer(var.get(), min, max)
# Return-value testing
if rv == 0:
input.config(bg=self.Color_White)
return True
elif rv == -1:
return True
else:
if rv == 1:
self.DisplayMessage("Value has erroneus format for field " + tag, 1)
elif rv == 2:
self.DisplayMessage("The number of decimals cannot exceed (" + str(ndec) + ") for field " + tag, 1)
elif rv == 3:
self.DisplayMessage("Value must be within the range[" + str(min) + "," + str(max) + "] for field " + tag, 1)
input.config(bg=self.Color_Red)
return False
return True