python: Provide sensible __str__ and __repr__ functions for enum values.

This fixes bug #668.
This commit is contained in:
Martin Ling 2016-01-03 22:22:57 +00:00 committed by Uwe Hermann
parent f014a8fd4c
commit c61e208d26
1 changed files with 10 additions and 0 deletions

View File

@ -426,6 +426,16 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
return (long) $self;
}
std::string __str__()
{
return $self->name();
}
std::string __repr__()
{
return "Class." + $self->name();
}
%pythoncode
{
def __eq__(self, other):