MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / createWrapper

Method createWrapper

src/Gui/MainWindowPy.cpp:94–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94Py::Object MainWindowPy::createWrapper(MainWindow* mw)
95{
96 PythonWrapper wrap;
97 if (!wrap.loadCoreModule() || !wrap.loadGuiModule() || !wrap.loadWidgetsModule()) {
98 throw Py::RuntimeError("Failed to load Python wrapper for Qt");
99 }
100
101 // copy attributes
102 static constexpr std::initializer_list<const char*> attr = {
103 "getWindows",
104 "getWindowsOfType",
105 "setActiveWindow",
106 "getActiveWindow",
107 "addWindow",
108 "removeWindow",
109 "showHint",
110 "hideHint",
111 "addStatusBarItem",
112 "removeStatusBarItem",
113 };
114
115 Py::Object py = wrap.fromQWidget(mw, "QMainWindow");
116 Py::ExtensionObject<MainWindowPy> inst(create(mw));
117 for (const auto& it : attr) {
118 py.setAttr(it, inst.getAttr(it));
119 }
120 return py;
121}
122
123MainWindowPy::MainWindowPy(MainWindow* mw)
124 : _mw(mw)

Callers

nothing calls this directly

Calls 5

loadCoreModuleMethod · 0.80
loadGuiModuleMethod · 0.80
loadWidgetsModuleMethod · 0.80
fromQWidgetMethod · 0.80
createFunction · 0.50

Tested by

no test coverage detected