From 543d1a378a863b4b7e84418e52f2a899fc9f3e51 Mon Sep 17 00:00:00 2001 From: "mhochsteger@cerbsim.com" Date: Thu, 4 Nov 2021 13:02:35 +0100 Subject: [PATCH] no tk event handling when starting netgen.__main__ --- python/__init__.py | 6 ++++-- python/__main__.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/python/__init__.py b/python/__init__.py index 729bb6e8..0bbf3686 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -16,7 +16,9 @@ del os from . import libngpy -def Redraw(*args, **kwargs): +from .libngpy.meshvis import _Redraw + +def RedrawWithEventHandling(*args, **kwargs): try: if libngpy.meshvis._Redraw(*args, **kwargs): import netgen @@ -27,4 +29,4 @@ def Redraw(*args, **kwargs): except: pass - +Redraw = RedrawWithEventHandling diff --git a/python/__main__.py b/python/__main__.py index 795dcf64..00ecb5c9 100644 --- a/python/__main__.py +++ b/python/__main__.py @@ -8,6 +8,10 @@ def handle_arguments(): imp.load_module('__main__', pyfile, argv[1], (".py", "r", imp.PY_SOURCE)) def main(): + import netgen + # Use Redraw without event handling + netgen.Redraw = netgen._Redraw + try: import ngsolve except: @@ -16,3 +20,6 @@ def main(): th = threading.Thread(target=handle_arguments) th.start() win.tk.mainloop() + +if __name__ == "__main__": + sys.exit(main())