GiD - The personal pre and post processor

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Python print to file

To debug Python code it is always possible to print data of variables to a file, with something like this:

f=open('C:/temp/my_debug.txt','a')
f.write('hello world\n')
f.close()

Python show text with W

If Pyhton is running in GiD then can call the Tcl GiD procedure called W that show text in a window

e.g.

import tohil
tcl=tohil.import_tcl()
a=5.2
tcl.W(a)

will show a GiD window with the value of the variable a

Python force reload a file

Using our Tcl command GiD_Python_Import_File (that do tohil::import) will import a module in Python,

but if we are developing and modify the .py file doing a new import don’t refresh the code in the interpreter.

A trick to do it it to use the Tcl command GiD_Python_Source,then the new code of the file is used without need to restart GiD.

In fact it seems that this is similar to use in Python the function reload of the importlib module

import importlib
importlib.reload(module)

  • No labels