def getEditorPropertyTypeAndValue(pythonDataType, currentValue): """ Gets the editor options and the pythonised value based on the python data type and the native CEGUI type value. Converts the value to the right internal python class for the given cegui type. :param pythonDataType: :param currentValue: :return: """ # get the callable that creates this data type # and the Property type to use. if issubclass(pythonDataType, ct.Base): # if it is a subclass of our ceguitypes, do some special handling value = pythonDataType.fromString( pythonDataType.toString(currentValue)) propertyType = pythonDataType.getPropertyType() else: if currentValue is None: value = None elif pythonDataType is bool: # The built-in bool parses "false" as True # so we replace the default value creator. value = ptUtility.boolFromString(currentValue) else: value = pythonDataType(currentValue) propertyType = properties.Property return value, propertyType
def getEditorPropertyTypeAndValue(pythonDataType, currentValue): """ Gets the editor options and the pythonised value based on the python data type and the native CEGUI type value. Converts the value to the right internal python class for the given cegui type. :param pythonDataType: :param currentValue: :return: """ # get the callable that creates this data type # and the Property type to use. if issubclass(pythonDataType, ct.Base): # if it is a subclass of our ceguitypes, do some special handling value = pythonDataType.fromString(pythonDataType.toString(currentValue)) propertyType = pythonDataType.getPropertyType() else: if currentValue is None: value = None elif pythonDataType is bool: # The built-in bool parses "false" as True # so we replace the default value creator. value = ptUtility.boolFromString(currentValue) else: value = pythonDataType(currentValue) propertyType = properties.Property return value, propertyType
def getCeguiTypeValueFromString(pythonDataType, valueAsString): """ Returns a CEGUI-typed object based on a given string and Python type :param pythonDataType: :param valueAsString: str :return: """ print valueAsString from ceed.cegui import ceguitypes as ceguiTypes if issubclass(pythonDataType, ceguiTypes.Base): # if the type is a subtype of the python cegui type, then use the conversion function value = pythonDataType.tryToCeguiType(valueAsString) else: if valueAsString is None: value = None elif pythonDataType is bool: # The built-in bool parses "false" as True # so we replace the default value creator. from ceed.propertytree import utility as propertyTreeUtility value = propertyTreeUtility.boolFromString(valueAsString) elif pythonDataType is unicode: value = valueAsString return value
def getCeguiTypeValueFromString(pythonDataType, valueAsString): """ Returns a CEGUI-typed object based on a given string and Python type :param pythonDataType: :param valueAsString: str :return: """ from ceed.cegui import ceguitypes as ceguiTypes if issubclass(pythonDataType, ceguiTypes.Base): # if the type is a subtype of the python cegui type, then use the conversion function value = pythonDataType.tryToCeguiType(valueAsString) else: if valueAsString is None: value = None elif pythonDataType is bool: # The built-in bool parses "false" as True # so we replace the default value creator. from ceed.propertytree import utility as propertyTreeUtility value = propertyTreeUtility.boolFromString(valueAsString) elif pythonDataType is unicode: value = valueAsString return value