本文整理汇总了Python中ctypes.Structure类的典型用法代码示例。如果您正苦于以下问题:Python Structure类的具体用法?Python Structure怎么用?Python Structure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Structure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
self.__enums = dict((f, t) for f, t in self._fields_
if issubclass_(t, Enum))
for field, val in iteritems(self._defaults_):
setattr(self, field, val)
Structure.__init__(self, *args, **kwargs)
示例2: __init__
def __init__ (self, pixel, line, x, y, z = 0.0):
Structure.__init__(self)
self.pixel = pixel
self.line = line
self.x = x
self.y = y
self.z = 0.0
示例3: __init__
def __init__(self, **kwargs):
Structure.__init__(self)
self.cbSize = sizeof(self)
for field_name, field_value in kwargs.items():
if isinstance(field_value, string_types):
field_value = ensure_binary(field_value)
setattr(self, field_name, field_value)
示例4: __init__
def __init__(self, text):
if isinstance(text, str):
text = text.encode(sys.getdefaultencoding())
elif not isinstance(text, bytes):
msg = "dbm mapping keys must be a string or bytes object, not {!r}"
raise TypeError(msg.format(type(text).__name__))
Structure.__init__(self, text, len(text))
示例5: __init__
def __init__(self, pmid, typeof, indom, sem, units):
Structure.__init__(self)
self.m_user = None
self.m_desc.pmid = pmid
self.m_desc.type = typeof
self.m_desc.indom = indom
self.m_desc.sem = sem
self.m_desc.units = units
示例6: __init__
def __init__(self, *_args):
Structure.__init__(self)
#
# Need to bind the following to the instance so it is available in
# `__del__()` when the interpreter shuts down.
#
self._free_chip_name = _free_chip_name
self.byref = byref
示例7: __init__
def __init__(self, serial, shorttext = '', helptext = ''):
Structure.__init__(self)
if type(helptext) != type(b''):
helptext = helptext.encode('utf-8')
if type(shorttext) != type(b''):
shorttext = shorttext.encode('utf-8')
self.shorttext = shorttext
self.helptext = shorttext
self.serial = serial
示例8: __init__
def __init__(self, virtual_keycode, down):
scancode = windll.user32.MapVirtualKeyA(virtual_keycode, 0)
flags = 0
if not down:
flags |= win32con.KEYEVENTF_KEYUP
if virtual_keycode in self.extended_keys:
flags |= win32con.KEYEVENTF_EXTENDEDKEY
extra = pointer(c_ulong(0))
Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra)
示例9: __init__
def __init__(self, value=None, max_length=0):
strbuf = None
length = 0
if value is not None or max_length > 0:
length = len(value)
max_length = max(length, max_length)
if value:
strbuf = create_unicode_buffer(value, max_length)
else:
strbuf = create_unicode_buffer(max_length)
Structure.__init__(self, length * 2, max_length * 2,
cast(strbuf, LPWSTR))
示例10: __init__
def __init__(self, name, item, typeof, semantics, dimension, indom = 0, shorttext = '', helptext = ''):
Structure.__init__(self)
if type(name) != type(b''):
name = name.encode('utf-8')
if type(helptext) != type(b''):
helptext = helptext.encode('utf-8')
if type(shorttext) != type(b''):
shorttext = shorttext.encode('utf-8')
self.shorttext = shorttext
self.helptext = shorttext
self.typeof = typeof
self.indom = indom
self.item = item
示例11: __init__
def __init__(self, **kwargs):
"""
Ctypes.Structure with integrated default values.
https://stackoverflow.com/questions/7946519/default-values-in-a-ctypes-structure/25892189#25892189
:param kwargs: values different to defaults
:type kwargs: dict
"""
# sanity checks
defaults = type(self)._defaults_
assert type(defaults) is types.DictionaryType
# use defaults, but override with keyword arguments, if any
values = defaults.copy()
for (key, val) in kwargs.items():
values[key] = val
# appropriately initialize ctypes.Structure
#super().__init__(**values) # Python 3 syntax
return Structure.__init__(self, **values) # Python 2 syntax
示例12: __init__
def __init__(self, **kw):
self.r1 = Mat4.rowtype(*(kw.get('r1') or (1,0,0,0)))
self.r2 = Mat4.rowtype(*(kw.get('r2') or (0,1,0,0)))
self.r3 = Mat4.rowtype(*(kw.get('r3') or (0,0,1,0)))
self.r4 = Mat4.rowtype(*(kw.get('r4') or (0,0,0,1)))
Structure.__init__(self)
示例13: __init__
def __init__(self, categoryBits=0x1, maskBits=0xFFFF, groupIndex=0):
""" Initialize the filter with the proper defaults """
Structure.__init__(self, categoryBits=categoryBits, maskBits=maskBits, groupIndex=groupIndex)
示例14: __init__
def __init__(self):
Structure.__init__(self, 512+9*4)
示例15: __init__
def __init__(self, **kwargs):
""" Initialize the Fixture Def """
if "filter" not in kwargs:
kwargs["filter"] = Filter()
Structure.__init__(self, **kwargs)