#	def __store__( cls, value ):
#		"""Return a stable, low-level representation of the value
#
#		In this case, an ISO date-string for the UTC value of the
#		DateTime
#		"""
#		gm = value.gmtime()
#		return gm.Format('%Y-%m-%dT%H:%M:')+str(gm.second)
#	__store__ = classmethod( __store__ )
#	def __unstore__( cls, value ):
#		"""Take our opaque date-store value and convert to an instance
#		"""
#		gm = DateTimeFrom( value )
#		return gm.localtime()
#	__unstore__ = classmethod( __unstore__ )
registry.registerDT(DateTimeType, mxDateTime_DT)


class _TimeParser(object):
    """Class providing time-parsing functionality"""
    HOUR_RE = '\d+'
    MINUTE_RE = '\d+'
    SECOND_RE = '(\d+([.]\d+)?)|([.]\d+)'
    PM_RE = 'p[.]?[m]?[.]?'
    AM_RE = 'a[.]?[m]?[.]?'

    TEMPLATE_RE = """
	(?P<hour>%(hour)s)
	(
		[:,.]
		(?P<minute>%(minute)s)?
Beispiel #2
0
		if isinstance( value, (tuple,list)):
			return cls( *value )
		elif isinstance( value, dict ):
			return cls( **value )
		else:
			set = {}
			for attribute in cls.coreAttributes+cls.extraAttributes:
				method = 'Get%s'%(attribute.capitalize())
				if hasattr( value, attribute ):
					set[attribute] = getattr(value,attribute)
				elif hasattr( value, method):
					set[attribute] = getattr(value,method)()
			return cls( **set )
	coerce = classmethod( coerce )
		
registry.registerDT( wx.PenPtr, wxPen)

def defaultPen( ):
	return wx.BLACK_PEN

PenStyleSet = enumeration.EnumerationSet()
PenStyleSet.new(name='wxSHORT_DASH',value=wx.SHORT_DASH,friendlyName='Short Dash')
PenStyleSet.new(name='wxSOLID',value=wx.SOLID,friendlyName='Solid ')
PenStyleSet.new(name='wxCROSS_HATCH',value=wx.CROSS_HATCH,friendlyName='Cross-Hatching')
PenStyleSet.new(name='wxVERTICAL_HATCH',value=wx.VERTICAL_HATCH,friendlyName='Vertical Hatching')
PenStyleSet.new(name='wxFDIAGONAL_HATCH',value=wx.FDIAGONAL_HATCH,friendlyName='Forward Diagonal Hatching')
PenStyleSet.new(name='wxLONG_DASH',value=wx.LONG_DASH,friendlyName='Long Dash')
PenStyleSet.new(name='wxUSER_DASH',value=wx.USER_DASH,friendlyName='User Defined Dash')
PenStyleSet.new(name='wxCROSSDIAG_HATCH',value=wx.CROSSDIAG_HATCH,friendlyName='Cross-Diagonal Hatching')
PenStyleSet.new(name='wxHORIZONTAL_HATCH',value=wx.HORIZONTAL_HATCH,friendlyName='Horizontal Hatching')
PenStyleSet.new(name='wxSTIPPLE',value=wx.STIPPLE,friendlyName='Stippled')
Beispiel #3
0
    """Generic "object" data-type
	"""
    dataType = 'object'
    baseType = object

    def coerce(cls, value):
        """Coerce value to the appropriate data type"""
        if cls.check(value):
            return value
        raise TypeError("""Don't know how to convert %r to a %s""" %
                        (value, cls.dataType))

    coerce = classmethod(coerce)


registry.registerDT(object, Object_DT)


class String_DT(datatypedefinition.BaseType_DT):
    """String (Unicode) data-type specifier"""
    dataType = "str"
    baseType = unicode

    def coerce(cls, value):
        """Coerce value to Unicode value

		Accepted values:
			None -- u""
			str instance -- value.decode()
			int,float,long,complex -- unicode(value)
		"""
Beispiel #4
0
"""Data-type definition for wxPython font class"""
from wxPython.wx import *
from basictypes import datatypedefinition, registry

##from basictypes.wx import wxcopyreg

__all__ = ("wxFont_DT",)


class wxFont_DT(datatypedefinition.BaseType_DT):
    """Data-type definition for wxPython font class"""

    dataType = "wx.font"
    baseType = wxFontPtr


registry.registerDT(wxFontPtr, wxFont_DT)
registry.registerDT(wxFont, wxFont_DT)
Beispiel #5
0
from basictypes import latebind, datatypedefinition, registry, booleanfix
import types, traceback

class Object_DT( datatypedefinition.BaseType_DT ):
	"""Generic "object" data-type
	"""
	dataType = 'object'
	baseType = object
	def coerce(cls, value):
		"""Coerce value to the appropriate data type"""
		if cls.check( value):
			return value
		raise TypeError( """Don't know how to convert %r to a %s"""%( value, cls.dataType))
	coerce = classmethod( coerce )

registry.registerDT( object, Object_DT )
class String_DT( datatypedefinition.BaseType_DT ):
	"""String (Unicode) data-type specifier"""
	dataType = "str"
	baseType = unicode
	def coerce(cls, value):
		"""Coerce value to Unicode value

		Accepted values:
			None -- u""
			str instance -- value.decode()
			int,float,long,complex -- unicode(value)
		"""
		if cls.check( value ):
			return value
		if value is None:
Beispiel #6
0
        elif isinstance(value, dict):
            return cls(**value)
        else:
            set = {}
            for attribute in cls.coreAttributes + cls.extraAttributes:
                method = 'Get%s' % (attribute.capitalize())
                if hasattr(value, attribute):
                    set[attribute] = getattr(value, attribute)
                elif hasattr(value, method):
                    set[attribute] = getattr(value, method)()
            return cls(**set)

    coerce = classmethod(coerce)


registry.registerDT(wx.PenPtr, wxPen)


def defaultPen():
    return wx.BLACK_PEN


PenStyleSet = enumeration.EnumerationSet()
PenStyleSet.new(name='wxSHORT_DASH',
                value=wx.SHORT_DASH,
                friendlyName='Short Dash')
PenStyleSet.new(name='wxSOLID', value=wx.SOLID, friendlyName='Solid ')
PenStyleSet.new(name='wxCROSS_HATCH',
                value=wx.CROSS_HATCH,
                friendlyName='Cross-Hatching')
PenStyleSet.new(name='wxVERTICAL_HATCH',
Beispiel #7
0
				rest = value[1:]
				if rest:
					value = int( rest, 16)
					return wx.Colour( value >> 16  & 255, value >> 8  & 255, value & 255 )
				else:
					return wx.Colour( 0,0,0)
			else:
				try:
					obj = wx.Colour( value )
				except (ValueError,TypeError):
					global COLOUR_DB_INITIALISED
					if not COLOUR_DB_INITIALISED:
						COLOUR_DB_INITIALISED = 1
						colourdb.updateColourDB()
					obj = wx.NamedColour( value )
					if not obj.Ok():
						raise ValueError( """Unrecognised string value %r for Colour value"""%(value))
		elif isinstance( value, (tuple,list) ):
			if len(value) == 3:
				obj = wx.Colour( *value )
			else:
				raise ValueError( """Unable to create wx.Colour from %r, incorrect length"""%( value ))
		elif value is None:
			return wx.Colour( 0,0,0)
		else:
			raise TypeError( """Unable to convert value %r (type %s) to wx.Colour object"""%( value, type(value)))
		return obj
	coerce = classmethod( coerce )
registry.registerDT( wx.Colour, wxColour_DT)
registry.registerDT( wx.ColourPtr, wxColour_DT)
Beispiel #8
0
"""Data-type definition for wxPython font class"""
from wxPython.wx import *
from basictypes import datatypedefinition, registry
##from basictypes.wx import wxcopyreg

__all__ = ( "wxFont_DT", )

class wxFont_DT( datatypedefinition.BaseType_DT ):
	"""Data-type definition for wxPython font class"""
	dataType = "wx.font"
	baseType = wxFontPtr
registry.registerDT( wxFontPtr, wxFont_DT)
registry.registerDT( wxFont, wxFont_DT)
#	def __store__( cls, value ):
#		"""Return a stable, low-level representation of the value
#
#		In this case, an ISO date-string for the UTC value of the
#		DateTime
#		"""
#		gm = value.gmtime()
#		return gm.Format('%Y-%m-%dT%H:%M:')+str(gm.second)
#	__store__ = classmethod( __store__ )
#	def __unstore__( cls, value ):
#		"""Take our opaque date-store value and convert to an instance
#		"""
#		gm = DateTimeFrom( value )
#		return gm.localtime()
#	__unstore__ = classmethod( __unstore__ )
registry.registerDT(DateTimeType, mxDateTime_DT)


class _TimeParser(object):
    """Class providing time-parsing functionality"""
    HOUR_RE = '\d+'
    MINUTE_RE = '\d+'
    SECOND_RE = '(\d+([.]\d+)?)|([.]\d+)'
    PM_RE = 'p[.]?[m]?[.]?'
    AM_RE = 'a[.]?[m]?[.]?'

    TEMPLATE_RE = """
	(?P<hour>%(hour)s)
	(
		[:,.]
		(?P<minute>%(minute)s)?