diff --git a/tutorial/c++/t1.cpp b/tutorial/c++/t1.cpp
index 8dcca235fe24300c57af0807e358fd19d4672a0d..9f9d902578723124a970125c64181ee1d3ec829e 100644
--- a/tutorial/c++/t1.cpp
+++ b/tutorial/c++/t1.cpp
@@ -6,6 +6,8 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
+
 // The Gmsh C++ API is entirely defined in the `gmsh.h' header (which contains
 // the full documentation of all the functions in the API):
 #include <gmsh.h>
@@ -146,9 +148,11 @@ int main(int argc, char **argv)
   // the format explicitly, and just choose a filename with the `.msh2' or
   // `.msh4' extension.
 
-  // To visualize the model we could run the graphical user interface with:
-  //
-  // gmsh::fltk::run();
+  // To visualize the model we can run the graphical user interface with
+  // `gmsh::fltk::run()'. Here we run it only if the "-nopopup" is not provided
+  // in the command line arguments:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   // Note that starting with Gmsh 3.0, models can be built using other geometry
   // kernels than the default "built-in" kernel. To use the OpenCASCADE geometry
diff --git a/tutorial/c++/t10.cpp b/tutorial/c++/t10.cpp
index f539a1e68fc3ee5ffdb31ea7102b5352ff0fa58d..0525b0f4032e4db654f11ac2b25f124537141bf5 100644
--- a/tutorial/c++/t10.cpp
+++ b/tutorial/c++/t10.cpp
@@ -10,8 +10,9 @@
 // (see `t1.cpp') or using a background mesh (see `t7.cpp'), you can use general
 // mesh size "Fields".
 
-#include <gmsh.h>
+#include <set>
 #include <sstream>
+#include <gmsh.h>
 
 int main(int argc, char **argv)
 {
@@ -146,7 +147,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(2);
   gmsh::write("t10.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t11.cpp b/tutorial/c++/t11.cpp
index b3601fb53086ac931bdde4d480a20c3e4eefe822..b7c897f0596f6cc6e02021b9744d156fb90cedea 100644
--- a/tutorial/c++/t11.cpp
+++ b/tutorial/c++/t11.cpp
@@ -6,6 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -91,7 +92,9 @@ int main(int argc, char **argv)
   // gmsh::option::setNumber("Mesh.SubdivisionAlgorithm", 1);
   // gmsh::model::mesh::refine();
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t12.cpp b/tutorial/c++/t12.cpp
index 9edc3924259f3cc7c5a9c7ccce939a6e09ed6252..f41656726fb006e397d7e86c3331eceb738cb0b8 100644
--- a/tutorial/c++/t12.cpp
+++ b/tutorial/c++/t12.cpp
@@ -6,6 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <gmsh.h>
 
 // "Compound" meshing constraints allow to generate meshes across surface
@@ -92,7 +93,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(2);
   gmsh::write("t12.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
 
diff --git a/tutorial/c++/t13.cpp b/tutorial/c++/t13.cpp
index f162984b0651cd9f79bb4fe81ba4d6c50b6840fe..555f88286fb5234f1cfda1a6b433d8dff8bce038 100644
--- a/tutorial/c++/t13.cpp
+++ b/tutorial/c++/t13.cpp
@@ -6,8 +6,9 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
+#include <cmath>
 #include <gmsh.h>
-#include <math.h>
 
 int main(int argc, char **argv)
 {
@@ -74,7 +75,9 @@ int main(int argc, char **argv)
 
   gmsh::model::mesh::generate(3);
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t14.cpp b/tutorial/c++/t14.cpp
index 7a73d8638d6a36f1c5731d62331a463575941895..daadafa7d4188b8dea68f850f1a7ab4368ae7650 100644
--- a/tutorial/c++/t14.cpp
+++ b/tutorial/c++/t14.cpp
@@ -10,9 +10,10 @@
 // (co)homology space bases using a mesh of a model.  The representative basis
 // chains are stored in the mesh as physical groups of Gmsh, one for each chain.
 
-#include <gmsh.h>
-#include <math.h>
+#include <set>
+#include <cmath>
 #include <algorithm>
+#include <gmsh.h>
 
 int main(int argc, char **argv)
 {
@@ -132,12 +133,16 @@ int main(int argc, char **argv)
   // Generate the mesh and perform the requested homology computations
   gmsh::model::mesh::generate(3);
 
-  gmsh::write("t14.msh");
-
   // For more information, see M. Pellikka, S. Suuriniemi, L. Kettunen and
   // C. Geuzaine. Homology and cohomology computation in finite element
   // modeling. SIAM Journal on Scientific Computing 35(5), pp. 1195-1214, 2013.
 
+  gmsh::write("t14.msh");
+
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
   gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t15.cpp b/tutorial/c++/t15.cpp
index 0c5fa11c605aa6cd4a843748f011d43023a60053..204d30c428c5a40ab053f04f738b6d8769670097 100644
--- a/tutorial/c++/t15.cpp
+++ b/tutorial/c++/t15.cpp
@@ -14,6 +14,7 @@
 // Embedding constraints allow to force a mesh to be conformal to other lower
 // dimensional entities.
 
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -99,6 +100,10 @@ int main(int argc, char **argv)
 
   gmsh::write("t15.msh");
 
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
   gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t16.cpp b/tutorial/c++/t16.cpp
index 1671404f8e197aa6d6ed2b1bdf81d7fb83fb45ff..c258ae40b3a651214a7d5e7665fde14699c451c3 100644
--- a/tutorial/c++/t16.cpp
+++ b/tutorial/c++/t16.cpp
@@ -10,6 +10,7 @@
 // geometry kernel, starting with version 3 Gmsh allows you to directly use
 // alternative geometry kernels. Here we will use the OpenCASCADE kernel.
 
+#include <set>
 #include <iostream>
 #include <gmsh.h>
 
@@ -138,8 +139,9 @@ int main(int argc, char **argv)
   std::cout << "Logger has recorded " << log.size() << " lines" << std::endl;
   gmsh::logger::stop();
 
-  // Show the GUI:
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t17.cpp b/tutorial/c++/t17.cpp
index ed7e5892110071bc5e190fcbf42a991e5ebf488b..53436db6d7a3bd9bbd4285264ee16a630df7a461 100644
--- a/tutorial/c++/t17.cpp
+++ b/tutorial/c++/t17.cpp
@@ -14,8 +14,9 @@
 // a square. One should use bamg as 2d mesh generator to enable anisotropic
 // meshes in 2D.
 
+#include <set>
+#include <cmath>
 #include <gmsh.h>
-#include <math.h>
 
 int main(int argc, char **argv)
 {
@@ -50,6 +51,10 @@ int main(int argc, char **argv)
 
   gmsh::write("t17.msh");
 
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
   gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t18.cpp b/tutorial/c++/t18.cpp
index 84577988f255c7a5b75c8da009bc086a07dd1ad4..e6c28e5b1a1b920f45538b6c547a6b0ddc7dec14 100644
--- a/tutorial/c++/t18.cpp
+++ b/tutorial/c++/t18.cpp
@@ -8,6 +8,7 @@
 
 // Periodic meshing constraints can be imposed on surfaces and curves.
 
+#include <set>
 #include <algorithm>
 #include <gmsh.h>
 
@@ -138,7 +139,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(3);
   gmsh::write("t18.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t19.cpp b/tutorial/c++/t19.cpp
index 44e15b6f266d5eb42829e2b81fc32c9cf69df7e6..ee02a783fd1e94b80090880474113cb3dc991dd9 100644
--- a/tutorial/c++/t19.cpp
+++ b/tutorial/c++/t19.cpp
@@ -9,6 +9,7 @@
 // The OpenCASCADE geometry kernel supports several useful features for solid
 // modelling.
 
+#include <set>
 #include <cmath>
 #include <cstdlib>
 #include <gmsh.h>
@@ -101,6 +102,10 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(3);
   gmsh::write("t19.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
+  gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t2.cpp b/tutorial/c++/t2.cpp
index e115580619bbfd9de08badfbf68d93a52fb050b7..4030abcf3c357f6238ed978036f2f8682f108ce9 100644
--- a/tutorial/c++/t2.cpp
+++ b/tutorial/c++/t2.cpp
@@ -6,8 +6,9 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
+#include <cmath>
 #include <gmsh.h>
-#include <math.h>
 
 int main(int argc, char **argv)
 {
@@ -164,6 +165,10 @@ int main(int argc, char **argv)
   // OpenCASCADE BRep file; or export an OpenCASCADE model as an Unrolled GEO
   // file.
 
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
   gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t20.cpp b/tutorial/c++/t20.cpp
index 98fca4ec02a75b991bed8c87fba243e8f0027c8f..1eec46c04b348bd70988bb3520437957b88fd404 100644
--- a/tutorial/c++/t20.cpp
+++ b/tutorial/c++/t20.cpp
@@ -10,10 +10,11 @@
 // them. In this tutorial we will load a STEP geometry and partition it into
 // slices.
 
+#include <set>
 #include <cmath>
 #include <cstdlib>
-#include <gmsh.h>
 #include <algorithm>
+#include <gmsh.h>
 
 int main(int argc, char **argv)
 {
@@ -140,8 +141,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(3);
   gmsh::write("t20.msh");
 
-  // Show the result:
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t21.cpp b/tutorial/c++/t21.cpp
index 54bd5098569e9f396e3bb37ed1e8073a79ee40ce..36efbf093e3703bd04f79c4fc4eb3061c2a11134 100644
--- a/tutorial/c++/t21.cpp
+++ b/tutorial/c++/t21.cpp
@@ -6,11 +6,12 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <cmath>
 #include <cstdlib>
-#include <gmsh.h>
 #include <algorithm>
 #include <iostream>
+#include <gmsh.h>
 
 // Gmsh can partition meshes using different algorithms, e.g. the graph
 // partitioner Metis or the `SimplePartition' plugin. For all the partitioning
@@ -129,7 +130,9 @@ int main(int argc, char **argv)
     }
   }
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t3.cpp b/tutorial/c++/t3.cpp
index 727cedd8bc8b1f300ec4b97707a39b435ae11cf1..cf030e34318aa91865943d3df4cf7cd7cff48bb7 100644
--- a/tutorial/c++/t3.cpp
+++ b/tutorial/c++/t3.cpp
@@ -6,6 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <cmath>
 #include <gmsh.h>
 
@@ -93,8 +94,8 @@ int main(int argc, char **argv)
   gmsh::option::setColor("Geometry.Surfaces", r, g, b, a);
 
   // Launch the GUI to see the effects of the color changes:
-
-  // gmsh::fltk::run();
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   // When the GUI is launched, you can use the `Help->Current Options and
   // Workspace' menu to see the current values of all options. To save the
diff --git a/tutorial/c++/t4.cpp b/tutorial/c++/t4.cpp
index 54a2d67e7215c11d8b1a46464656df2ca3c52065..f4326008f4f49b025f0a6414462c6b95a13bacfb 100644
--- a/tutorial/c++/t4.cpp
+++ b/tutorial/c++/t4.cpp
@@ -7,7 +7,7 @@
 // -----------------------------------------------------------------------------
 
 #include <set>
-#include <math.h>
+#include <cmath>
 #include <gmsh.h>
 
 double hypoth(double a, double b) { return sqrt(a * a + b * b); }
@@ -168,9 +168,8 @@ int main(int argc, char **argv)
   gmsh::write("t4.msh");
 
   // Launch the GUI to see the results:
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t5.cpp b/tutorial/c++/t5.cpp
index 8927ea6be9b8bd04314016be49163d8ef090d284..a0330add241a547885d0b97095c91a4ca542a5dd 100644
--- a/tutorial/c++/t5.cpp
+++ b/tutorial/c++/t5.cpp
@@ -6,8 +6,9 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <gmsh.h>
+#include <set>
 #include <cstdio>
+#include <gmsh.h>
 
 void cheeseHole(double x, double y, double z, double r, double lc,
                 std::vector<int> &shells, std::vector<int> &volumes)
@@ -223,7 +224,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(3);
   gmsh::write("t5.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
 
diff --git a/tutorial/c++/t6.cpp b/tutorial/c++/t6.cpp
index bc19ac033bc3148b88ed910c6d2f47026de0c952..152bea963b353baa2ed0106a21a21ce9de560b71 100644
--- a/tutorial/c++/t6.cpp
+++ b/tutorial/c++/t6.cpp
@@ -6,6 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -99,6 +100,11 @@ int main(int argc, char **argv)
   gmsh::model::geo::synchronize();
   gmsh::model::mesh::generate(2);
   gmsh::write("t6.msh");
+
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
+
   gmsh::finalize();
   return 0;
 }
diff --git a/tutorial/c++/t7.cpp b/tutorial/c++/t7.cpp
index 777a2db8713bd82c64565f4554a6d697df6a6900..efe1f5a9c96e442f69f1747231b2c54bcc256f2b 100644
--- a/tutorial/c++/t7.cpp
+++ b/tutorial/c++/t7.cpp
@@ -65,9 +65,8 @@ int main(int argc, char **argv)
   gmsh::write("t7.msh");
 
   // Launch the GUI to see the results:
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t8.cpp b/tutorial/c++/t8.cpp
index 8b445c95b609c153693d9fc8830f61ad11002053..9dd443e63c55cfb6253ee57e93371ee068c7ecb2 100644
--- a/tutorial/c++/t8.cpp
+++ b/tutorial/c++/t8.cpp
@@ -72,10 +72,9 @@ int main(int argc, char **argv)
   gmsh::option::setNumber("General.Axes", 0);
   gmsh::option::setNumber("General.SmallAxes", 0);
 
-  // Show the GUI
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::initialize();
+  // Show the GUI:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::initialize();
 
   // We also set some options for each post-processing view:
   gmsh::option::setNumber("View[0].IntervalsType", 2);
@@ -164,7 +163,7 @@ int main(int argc, char **argv)
     }
   }
 
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
 
diff --git a/tutorial/c++/t9.cpp b/tutorial/c++/t9.cpp
index cab6ffdfd677d75701dc97ab6d365511fc107459..bef92ec1e240a2b6a9ca5d9e2f544211404c74cc 100644
--- a/tutorial/c++/t9.cpp
+++ b/tutorial/c++/t9.cpp
@@ -75,10 +75,9 @@ int main(int argc, char **argv)
   gmsh::option::setNumber("View[1].IntervalsType", 2);
   gmsh::option::setNumber("View[2].IntervalsType", 2);
 
-  // show the GUI at the end
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/x2.cpp b/tutorial/c++/x2.cpp
index a4749acc51123709487c2f27bb430fc2b11206f2..5c45ed719ebdf81a942f30d5fcab64299b743bde 100644
--- a/tutorial/c++/x2.cpp
+++ b/tutorial/c++/x2.cpp
@@ -6,6 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
+#include <set>
 #include <iostream>
 #include <gmsh.h>
 
@@ -175,7 +176,9 @@ int main(int argc, char **argv)
   gmsh::model::mesh::generate(3);
   gmsh::write("x2.msh");
 
-  // gmsh::fltk::run();
+  // Launch the GUI to see the results:
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/x3.cpp b/tutorial/c++/x3.cpp
index 00009bfd46a0619a862a667f2483f021b5e85d29..d7e393acf512d4dfc2cd713e49b93ca184e021e5 100644
--- a/tutorial/c++/x3.cpp
+++ b/tutorial/c++/x3.cpp
@@ -164,9 +164,8 @@ int main(int argc, char **argv)
   gmsh::option::setNumber(v2 + ".MaxRecursionLevel", 5);
 
   // Launch the GUI to see the results:
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/x4.cpp b/tutorial/c++/x4.cpp
index 96c3832943868dda5873721d8c4f33d07124d558..e5fda981a9e0834812d344ad4a13d6bd35daf595 100644
--- a/tutorial/c++/x4.cpp
+++ b/tutorial/c++/x4.cpp
@@ -92,9 +92,8 @@ int main(int argc, char **argv)
   gmsh::view::write(t2, "x4_t2.msh");
 
   // Launch the GUI to see the results:
-  std::set<std::string> args;
-  for(int i = 1; i < argc; i++) args.insert(argv[i]);
-  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
+  std::set<std::string> args(argv, argv + argc);
+  if(!args.count("-nopopup")) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/julia/t1.jl b/tutorial/julia/t1.jl
index de01e2a8b1c980a8948f8e913acef970ded5db7b..67e09e0dd0fd5052a0a1e057a0fc460260e3d2f4 100644
--- a/tutorial/julia/t1.jl
+++ b/tutorial/julia/t1.jl
@@ -35,4 +35,8 @@ gmsh.model.mesh.generate(2)
 
 gmsh.write("t1.msh")
 
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/julia/t10.jl b/tutorial/julia/t10.jl
index d9dd656aa832ace8e1f71c54c8e05cf6f23d5e4b..830d32fad9b144dcb4856c955557918118a991aa 100644
--- a/tutorial/julia/t10.jl
+++ b/tutorial/julia/t10.jl
@@ -71,4 +71,8 @@ gmsh.option.setNumber("Mesh.CharacteristicLengthFromCurvature", 0)
 gmsh.model.mesh.generate(2)
 gmsh.write("t10.msh")
 
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/julia/t16.jl b/tutorial/julia/t16.jl
index 3ebf800ee19118a670a9ef741a195154441dc087..f73e0cc6f78fdd50444ff42b9ccd6cc4ee518785 100644
--- a/tutorial/julia/t16.jl
+++ b/tutorial/julia/t16.jl
@@ -45,4 +45,8 @@ gmsh.model.mesh.generate(3)
 
 gmsh.write("t16.msh")
 
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/julia/t2.jl b/tutorial/julia/t2.jl
index 62c24ace5778fba9f9de614a617d4a609cdc5aca..34bfcc2c31c5ab10105fc981e4d7c79b75d34d5a 100644
--- a/tutorial/julia/t2.jl
+++ b/tutorial/julia/t2.jl
@@ -88,4 +88,8 @@ gmsh.model.mesh.generate(3)
 
 gmsh.write("t2.msh")
 
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/julia/t3.jl b/tutorial/julia/t3.jl
index d5cf6d295c15827eb4c998a60015f9267cf5c7a9..f7430ca5e1776b89b3d2a4d3010df2f98423a454 100644
--- a/tutorial/julia/t3.jl
+++ b/tutorial/julia/t3.jl
@@ -37,4 +37,9 @@ gmsh.model.addPhysicalGroup(3, [1, 2, ov[2][2]], 101)
 gmsh.model.geo.synchronize()
 gmsh.model.mesh.generate(3)
 gmsh.write("t3.msh")
+
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/julia/t4.jl b/tutorial/julia/t4.jl
index c62f2727212e9708bb530fbdaf3fe204761d6fbb..b05bf3ac3d02ef03e7ef21145b77aed46459b235 100644
--- a/tutorial/julia/t4.jl
+++ b/tutorial/julia/t4.jl
@@ -115,7 +115,6 @@ gmsh.model.mesh.generate(2)
 
 gmsh.write("t4.msh")
 
-# Launch the GUI to see the results:
 if !("-nopopup" in ARGS)
     gmsh.fltk.run()
 end
diff --git a/tutorial/julia/t5.jl b/tutorial/julia/t5.jl
index 7bbcbb5f63c05213ae0ae977f594f59c5d180abf..61cfec1eed2331860830f488961b4adb3e6e6025 100644
--- a/tutorial/julia/t5.jl
+++ b/tutorial/julia/t5.jl
@@ -122,9 +122,12 @@ gmsh.model.geo.addVolume(shells, 186);
 
 gmsh.model.addPhysicalGroup(3, [186], 10);
 gmsh.model.geo.synchronize()
-gmsh.fltk.run()
 
 gmsh.model.mesh.generate(3)
 gmsh.write("t5.msh")
 
+if !("-nopopup" in ARGS)
+    gmsh.fltk.run()
+end
+
 gmsh.finalize()
diff --git a/tutorial/python/t1.py b/tutorial/python/t1.py
index f0718a1ed3eec93805c5a7c12f64fd0bbf17a40f..6296b3f14af52209715c4e6b1b7c66dc0446775f 100644
--- a/tutorial/python/t1.py
+++ b/tutorial/python/t1.py
@@ -9,6 +9,7 @@
 # The Python API is entirely defined in the `gmsh.py' module (which contains the
 # full documentation of all the functions in the API):
 import gmsh
+import sys
 
 # Before using any functions in the Python API, Gmsh must be initialized:
 gmsh.initialize()
@@ -141,9 +142,11 @@ gmsh.write("t1.msh")
 # format explicitly, and just choose a filename with the `.msh2' or `.msh4'
 # extension.
 
-# To visualize the model we could run the graphical user interface with:
-#
-# gmsh.fltk.run()
+# To visualize the model we can run the graphical user interface with
+# `gmsh.fltk.run()'. Here we run it only if the "-nopopup" is not provided in
+# the command line arguments:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 # Note that starting with Gmsh 3.0, models can be built using other geometry
 # kernels than the default "built-in" kernel. To use the OpenCASCADE geometry
diff --git a/tutorial/python/t10.py b/tutorial/python/t10.py
index 635f9f68b055f267246f9a230f381f0f2ebf4dd0..107e3bdccec7374b7663819a2e24cb27a92abed1 100644
--- a/tutorial/python/t10.py
+++ b/tutorial/python/t10.py
@@ -138,6 +138,8 @@ gmsh.option.setNumber("Mesh.CharacteristicLengthFromCurvature", 0)
 gmsh.model.mesh.generate(2)
 gmsh.write("t10.msh")
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t11.py b/tutorial/python/t11.py
index c61705b8c89e8218eb3531127b95f52c0dee08ec..5c52c9f0ce7d338c7288e9c8aac076feeb1e5f3c 100644
--- a/tutorial/python/t11.py
+++ b/tutorial/python/t11.py
@@ -7,6 +7,7 @@
 # ------------------------------------------------------------------------------
 
 import gmsh
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -89,6 +90,8 @@ gmsh.model.mesh.generate(2)
 # gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
 # gmsh.model.mesh.refine()
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t12.py b/tutorial/python/t12.py
index 20ca52fc5b82302ad2b7fd99554fcfd7d3b61938..22ed7710db077bc88518c60d82c763a98c6c797a 100644
--- a/tutorial/python/t12.py
+++ b/tutorial/python/t12.py
@@ -7,6 +7,7 @@
 # ------------------------------------------------------------------------------
 
 import gmsh
+import sys
 
 # "Compound" meshing constraints allow to generate meshes across surface
 # boundaries, which can be useful e.g. for imported CAD models (e.g. STEP) with
@@ -88,6 +89,8 @@ gmsh.model.mesh.setCompound(2, [1, 5, 10])
 gmsh.model.mesh.generate(2)
 gmsh.write('t12.msh')
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t13.py b/tutorial/python/t13.py
index 209cb7b7c1caef217ba99137ed27de9705aa3ee1..36fe3fb47742a06708c3fff86d44716e6878776f 100644
--- a/tutorial/python/t13.py
+++ b/tutorial/python/t13.py
@@ -9,6 +9,7 @@
 import gmsh
 import math
 import os
+import sys
 
 gmsh.initialize()
 
@@ -64,6 +65,8 @@ gmsh.model.mesh.field.setAsBackgroundMesh(f)
 gmsh.model.mesh.generate(3)
 gmsh.write('t13.msh')
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t14.py b/tutorial/python/t14.py
index b60df75fe7e94f72012e40221eaae37a2935e37b..d52a34f4a2752b4f0374d45cd328f7550acf6a3c 100644
--- a/tutorial/python/t14.py
+++ b/tutorial/python/t14.py
@@ -140,4 +140,9 @@ gmsh.model.mesh.generate(3)
 # modeling. SIAM Journal on Scientific Computing 35(5), pp. 1195-1214, 2013.
 
 gmsh.write("t14.msh")
+
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
+
 gmsh.finalize()
diff --git a/tutorial/python/t15.py b/tutorial/python/t15.py
index 0c89bb5bbda56b2b6f6e88ca61970ca683a392fd..357d38c912c1806a2d2e3a80e8aeb78d2f32fdad 100644
--- a/tutorial/python/t15.py
+++ b/tutorial/python/t15.py
@@ -15,6 +15,7 @@
 # dimensional entities.
 
 import gmsh
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -95,4 +96,8 @@ gmsh.model.mesh.generate(3)
 
 gmsh.write("t15.msh")
 
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
+
 gmsh.finalize()
diff --git a/tutorial/python/t16.py b/tutorial/python/t16.py
index 706214f6409b7c63419b72748f7974b7999a65c5..b98b689071318b7db536c17a067334853a3d4fa4 100644
--- a/tutorial/python/t16.py
+++ b/tutorial/python/t16.py
@@ -12,6 +12,7 @@
 
 import gmsh
 import math
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -118,7 +119,8 @@ log = gmsh.logger.get()
 print("Logger has recorded " + str(len(log)) + " lines")
 gmsh.logger.stop()
 
-# Show the GUI:
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t17.py b/tutorial/python/t17.py
index caf8f5074dcbc35f7ec9c348514af1cfa1782284..0abd78e1002ec2d5f6da58e36920177a8c24e0fa 100644
--- a/tutorial/python/t17.py
+++ b/tutorial/python/t17.py
@@ -17,6 +17,7 @@
 import gmsh
 import math
 import os
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -43,6 +44,8 @@ gmsh.option.setNumber("Mesh.Algorithm", 7)
 gmsh.model.mesh.generate(2)
 gmsh.write("t17.msh")
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t18.py b/tutorial/python/t18.py
index 42c3e67a1f07228c7e74b4f6603a6b96da39e868..c7dab984d9ed782e2e40e5337a8b8e0efe8dec9c 100644
--- a/tutorial/python/t18.py
+++ b/tutorial/python/t18.py
@@ -11,6 +11,7 @@
 import gmsh
 import math
 import os
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -121,6 +122,8 @@ for i in sxmin:
 gmsh.model.mesh.generate(3)
 gmsh.write("t18.msh")
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t19.py b/tutorial/python/t19.py
index 4dee47800d17c4a59ecc841375e7c439e9bac7e4..35b114769ce738b8d5593fb6d903d98980e0e49d 100644
--- a/tutorial/python/t19.py
+++ b/tutorial/python/t19.py
@@ -12,6 +12,7 @@
 import gmsh
 import math
 import os
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -92,4 +93,8 @@ gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 0.3)
 gmsh.model.mesh.generate(3)
 gmsh.write("t19.msh")
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
+
+gmsh.finalize()
diff --git a/tutorial/python/t2.py b/tutorial/python/t2.py
index 4e18179e64bcbcbff78a62c0cbae1f20949c5056..b5aa68decd77a1ce56361889a2aa4a442218aeed 100644
--- a/tutorial/python/t2.py
+++ b/tutorial/python/t2.py
@@ -157,4 +157,8 @@ gmsh.write("t2.msh")
 # a geometry constructed with the built-in kernel as an OpenCASCADE BRep file;
 # or export an OpenCASCADE model as an Unrolled GEO file.
 
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
+
 gmsh.finalize()
diff --git a/tutorial/python/t20.py b/tutorial/python/t20.py
index 417fe88ed1f09486b3a1760d70ae8808ed53d070..6874f694226faab0016acd4d7dc4c6ecd74ffc40 100644
--- a/tutorial/python/t20.py
+++ b/tutorial/python/t20.py
@@ -13,6 +13,7 @@
 import gmsh
 import math
 import os
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -111,7 +112,8 @@ gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 3)
 gmsh.model.mesh.generate(3)
 gmsh.write("t20.msh")
 
-# Show the result:
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t21.py b/tutorial/python/t21.py
index 8b3744e2c536f8975c5bf6e43555d9635464d88f..04f68f587e9e6497f59204dfa8a3683e608da067 100644
--- a/tutorial/python/t21.py
+++ b/tutorial/python/t21.py
@@ -7,6 +7,7 @@
 # ------------------------------------------------------------------------------
 
 import gmsh
+import sys
 
 # Gmsh can partition meshes using different algorithms, e.g. the graph
 # partitioner Metis or the `SimplePartition' plugin. For all the partitioning
@@ -98,6 +99,8 @@ for e in entities:
         print(" - Parent: " + str(gmsh.model.getParent(e[0], e[1])))
         print(" - Boundary: " + str(gmsh.model.getBoundary([e])))
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t3.py b/tutorial/python/t3.py
index a98e33851ea059908c6d4ac136ab1cae0c309a8f..bc8210cde6eb33666022086657fe86821252a0b4 100644
--- a/tutorial/python/t3.py
+++ b/tutorial/python/t3.py
@@ -8,6 +8,7 @@
 
 import gmsh
 import math
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -89,8 +90,8 @@ r, g, b, a = gmsh.option.getColor("Geometry.Points")
 gmsh.option.setColor("Geometry.Surfaces", r, g, b, a)
 
 # Launch the GUI to see the effects of the color changes:
-
-# gmsh.fltk.run();
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 # When the GUI is launched, you can use the `Help->Current Options and
 # Workspace' menu to see the current values of all options. To save the options
diff --git a/tutorial/python/t5.py b/tutorial/python/t5.py
index 21fd30d156e5b5269d80c2bf0c587e3a18cd78c6..9ba991eb203dac1b460d23be2a15db7dc9e753df 100644
--- a/tutorial/python/t5.py
+++ b/tutorial/python/t5.py
@@ -8,6 +8,7 @@
 
 import gmsh
 import math
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -218,6 +219,8 @@ gmsh.model.mesh.setAlgorithm(2, 33, 1)
 gmsh.model.mesh.generate(3)
 gmsh.write("t5.msh")
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()
diff --git a/tutorial/python/t6.py b/tutorial/python/t6.py
index 52f50e3258aceea7ab71f0ac9bd448864ea8d0b5..898f9251c37dff57d24d4cf118b8593dcdcf4744 100644
--- a/tutorial/python/t6.py
+++ b/tutorial/python/t6.py
@@ -8,6 +8,7 @@
 
 import gmsh
 import math
+import sys
 
 gmsh.initialize()
 gmsh.option.setNumber("General.Terminal", 1)
@@ -99,4 +100,9 @@ gmsh.option.setNumber("Mesh.Smoothing", 100)
 
 gmsh.model.mesh.generate(2)
 gmsh.write("t6.msh")
+
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
+
 gmsh.finalize()
diff --git a/tutorial/python/t8.py b/tutorial/python/t8.py
index 0f9f206b329b408121344724a181c2d9d828ad3b..da2286a2b0cbb032790f51aff17667289a2e605f 100644
--- a/tutorial/python/t8.py
+++ b/tutorial/python/t8.py
@@ -67,7 +67,7 @@ gmsh.option.setNumber("General.Orthographic", 0)
 gmsh.option.setNumber("General.Axes", 0)
 gmsh.option.setNumber("General.SmallAxes", 0)
 
-# Show the GUI
+# Show the GUI:
 if '-nopopup' not in sys.argv:
     gmsh.fltk.initialize()
 
diff --git a/tutorial/python/t9.py b/tutorial/python/t9.py
index a934df5c7b0a18fa1879ae9d90f6ce53797c9e56..494def879a3e5e4a475153fa00dccbd3ae2b6f58 100644
--- a/tutorial/python/t9.py
+++ b/tutorial/python/t9.py
@@ -67,7 +67,7 @@ gmsh.option.setNumber("View[0].SmoothNormals", 1)
 gmsh.option.setNumber("View[1].IntervalsType", 2)
 gmsh.option.setNumber("View[2].IntervalsType", 2)
 
-# show the GUI at the end
+# Launch the GUI to see the results:
 if '-nopopup' not in sys.argv:
     gmsh.fltk.run()
 
diff --git a/tutorial/python/x2.py b/tutorial/python/x2.py
index 2e9b1d079ed9668d9ebcca3cae5c94219bf9a27a..b6c79de9a4a6a8d3f30d2698eebc0b46ba273110 100644
--- a/tutorial/python/x2.py
+++ b/tutorial/python/x2.py
@@ -164,6 +164,8 @@ else:
 gmsh.model.mesh.generate(3)
 gmsh.write('x2.msh')
 
-# gmsh.fltk.run()
+# Launch the GUI to see the results:
+if '-nopopup' not in sys.argv:
+    gmsh.fltk.run()
 
 gmsh.finalize()