[TD]add check for Gui up

This commit is contained in:
wandererfan
2025-03-07 13:19:01 -05:00
parent 0a5b3f63a4
commit f9b6e2c33b
2 changed files with 9 additions and 0 deletions

View File

@@ -1887,6 +1887,14 @@ std::string DrawUtil::cleanFilespecBackslash(const std::string& filespec)
return noBackslash;
}
//! returns true if the Gui module and its event loop are active.
bool DrawUtil::isGuiUp()
{
std::string pyCommand{"import FreeCAD\nguiState = FreeCAD.GuiUp"};
std::string result{Base::Interpreter().runStringWithKey(pyCommand.c_str(), "guiState", "None")};
return (result == "1");
}
//============================
// various debugging routines.

View File

@@ -271,6 +271,7 @@ public:
static std::string cleanFilespecBackslash(const std::string& filespec);
static bool isGuiUp();
//debugging routines
static void dumpVertexes(const char* text, const TopoDS_Shape& s);