Start GUI from Python only if Netgen exe is not running

This commit is contained in:
Matthias Hochsteger 2017-05-15 18:56:47 +02:00
parent b4f3107fef
commit 9a7307fb39
2 changed files with 16 additions and 8 deletions

View File

@ -13,6 +13,7 @@ using namespace netgen;
namespace netgen namespace netgen
{ {
extern bool netgen_executable_started;
extern shared_ptr<NetgenGeometry> ng_geometry; extern shared_ptr<NetgenGeometry> ng_geometry;
} }
@ -49,6 +50,8 @@ static Transformation<3> global_trafo(Vec<3> (0,0,0));
DLL_HEADER void ExportNetgenMeshing(py::module &m) DLL_HEADER void ExportNetgenMeshing(py::module &m)
{ {
m.attr("_netgen_executable_started") = py::cast(netgen::netgen_executable_started);
py::class_<NGDummyArgument>(m, "NGDummyArgument") py::class_<NGDummyArgument>(m, "NGDummyArgument")
.def("__bool__", []( NGDummyArgument &self ) { return false; } ) .def("__bool__", []( NGDummyArgument &self ) { return false; } )
; ;

View File

@ -1,11 +1,16 @@
from tkinter import Tk import netgen
from . import _netgen_lib_dir def StartGUI():
from . import _netgen_bin_dir import os
from tkinter import Tk
win = Tk() from . import _netgen_lib_dir
import os from . import _netgen_bin_dir
dir_path = os.path.dirname(os.path.realpath(__file__))
win.tk.eval("source "+os.path.realpath(os.path.join(_netgen_bin_dir, 'ng.tcl')).replace('\\','/'))
# %gui tk global win
win = Tk()
dir_path = os.path.dirname(os.path.realpath(__file__))
win.tk.eval("source "+os.path.realpath(os.path.join(_netgen_bin_dir, 'ng.tcl')).replace('\\','/'))
if not netgen.libngpy._meshing._netgen_executable_started:
StartGUI()