...
Print to file
To debug Python code it is always possible to print data of variables to a file, with something like this:
Code Block |
---|
f=open('C:/temp/my_debug.txt','a') f.write('hello world\n') f.close() |
...
Python embedded in GiD
The scenery of use python in GiD is not usual:
...
then the debugger will be stopped in our break point and can inspect variables, etc.
...
.
...
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.
Code Block | ||
---|---|---|
| ||
import tohil
tcl=tohil.import_tcl()
a=5.2
tcl.W(a) |
will show a GiD window with the value of the variable a
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.