From 3bb804eeafb8e0173af59e3f594ec446fa82015a Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Fri, 31 May 2024 13:23:53 +0200 Subject: [PATCH] add dict constructor of flags for implicit convertion back --- libsrc/core/python_ngcore_export.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libsrc/core/python_ngcore_export.cpp b/libsrc/core/python_ngcore_export.cpp index a30e7f1b..d8666e6a 100644 --- a/libsrc/core/python_ngcore_export.cpp +++ b/libsrc/core/python_ngcore_export.cpp @@ -149,6 +149,12 @@ PYBIND11_MODULE(pyngcore, m) // NOLINT py::class_(m, "Flags") .def(py::init<>()) .def("__str__", &ToString) + .def(py::init([](py::dict kwargs) { + Flags flags; + for (auto d : kwargs) + SetFlag(flags, d.first.cast(), d.second.cast()); + return flags; + }), "Create flags from dict") .def(py::init([](py::kwargs kwargs) { Flags flags; for (auto d : kwargs)