| 92 | } |
| 93 | |
| 94 | Py::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 | |
| 123 | MainWindowPy::MainWindowPy(MainWindow* mw) |
| 124 | : _mw(mw) |
nothing calls this directly
no test coverage detected