I would like to make one of the fields of my ctypes.Structure
an enum. This post suggests adding a from_param
classmethod to the enum class, but claims that this isn't enough for a custom ctypes.Structure
. I've also tried inheriting from both enum.IntEnum
and ctypes.c_uint
but that results a metaclass conflict. Here is approximately what I want:
class MyEnum(enum.IntEnum):
A = 0
B = 1
class MyStruct(ctypes.Structure):
_fields_ = [
('my_enum', MyEnum),
...
]