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

Method addStatusBarItem

src/Gui/MainWindowPy.cpp:298–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298Py::Object MainWindowPy::addStatusBarItem(const Py::Tuple& args, const Py::Dict& kwds)
299{
300 PyObject* pyWidget {};
301 const char* id {};
302 const char* title = "";
303 const char* slot = "Right";
304 int order = 0;
305 int persistent = 1;
306 int stretch = 0;
307
308 // Parse positional + keyword arguments.
309 static char* argNames[] = {
310 const_cast<char*>("widget"),
311 const_cast<char*>("id"),
312 const_cast<char*>("title"),
313 const_cast<char*>("slot"),
314 const_cast<char*>("order"),
315 const_cast<char*>("persistentVisibility"),
316 const_cast<char*>("stretch"),
317 nullptr
318 };
319 if (!PyArg_ParseTupleAndKeywords(
320 args.ptr(),
321 kwds.ptr(),
322 "Os|ssipi",
323 argNames,
324 &pyWidget,
325 &id,
326 &title,
327 &slot,
328 &order,
329 &persistent,
330 &stretch
331 )) {
332 throw Py::Exception();
333 }
334
335 PythonWrapper wrap;
336 wrap.loadWidgetsModule();
337 QWidget* widget = qobject_cast<QWidget*>(wrap.toQObject(Py::Object(pyWidget)));
338 if (!widget) {
339 throw Py::TypeError("addStatusBarItem: first argument must be a QWidget");
340 }
341
342 StatusBarItemSpec spec;
343 spec.id = QByteArray(id);
344 spec.title = QString::fromUtf8(title);
345 spec.slot = (QByteArray(slot).toLower() == "left") ? StatusBarSlot::Left : StatusBarSlot::Right;
346 spec.order = order;
347 spec.persistentVisibility = persistent != 0;
348 spec.stretch = stretch;
349
350 if (_mw) {
351 _mw->addStatusBarItem(widget, spec);
352 }
353 return Py::None();
354}
355

Callers

nothing calls this directly

Calls 6

loadWidgetsModuleMethod · 0.80
toQObjectMethod · 0.80
ObjectClass · 0.70
QByteArrayClass · 0.70
ExceptionClass · 0.50
ptrMethod · 0.45

Tested by

no test coverage detected