<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FCedricshock</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FCedricshock"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FCedricshock"/>
	<updated>2026-05-27T22:23:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Python&amp;diff=2135</id>
		<title>GRASS and Python</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Python&amp;diff=2135"/>
		<updated>2006-07-15T20:45:00Z</updated>

		<summary type="html">&lt;p&gt;⚠️Cedricshock: /* Using Grass gui.tcl in python */ fixed bug in my code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Python extensions for GRASS GIS==&lt;br /&gt;
&lt;br /&gt;
===Python-SWIG-GRASS interface===&lt;br /&gt;
There is a prototype GRASS-SWIG interface available (thanks to Sajith VK), find it in GRASS 6-CVS: swig/python/&lt;br /&gt;
&lt;br /&gt;
Background: [http://www.swig.org SWIG] (Simplified Wrapper and Interface Generator) is: &lt;br /&gt;
&lt;br /&gt;
* A compiler that turns ANSI C/C++ declarations into scripting language interfaces.&lt;br /&gt;
* Completely automated (produces a fully working Python extension module). &lt;br /&gt;
* Language neutral. SWIG can also target Tcl, Perl, Guile, MATLAB, etc... &lt;br /&gt;
* Attempts to eliminate the tedium of writing extension modules.&lt;br /&gt;
&lt;br /&gt;
'''TODO''': Implement modules support in a Python class using --interface-description and a Python-XML parser. This should be a generic class with module's name as parameter, returning back an object which describes the module (description, flags, parameters, status of not/required). See [http://freegis.org/cgi-bin/viewcvs.cgi/grass6/gui/wxpython/ GRASS 6 wxPython interface] for inspiration. Important is to auto-generate the GRASS-Python class at compile time with a Python script.&lt;br /&gt;
&lt;br /&gt;
=== Python-GRASS add-ons ===&lt;br /&gt;
&lt;br /&gt;
Stand-alone addons:&lt;br /&gt;
&lt;br /&gt;
# Jáchym Čepický's G-ps.map, a GUI to typeset printable maps with ps.map (http://les-ejk.cz/?cat=gpsmap)&lt;br /&gt;
# Jáchym Čepický's v.pydigit, a GUI to v.edit (http://les-ejk.cz/?cat=vpydigit)&lt;br /&gt;
# Jáchym Čepický's PyWPS, GRASS-Web Processing Service (http://les-ejk.cz/?cat=pywps)&lt;br /&gt;
&lt;br /&gt;
=== Using Grass gui.tcl in python ===&lt;br /&gt;
&lt;br /&gt;
Here is some example code to use the grass automatically generated guis in python code. This could (should) all be bundled up and abstracted away so that the implementation can be replaced later.&lt;br /&gt;
&lt;br /&gt;
 import Tkinter&lt;br /&gt;
 import os&lt;br /&gt;
 &lt;br /&gt;
 # Startup (once):&lt;br /&gt;
 &lt;br /&gt;
 tk = Tkinter.Tk()&lt;br /&gt;
 tk.eval (&amp;quot;wm withdraw .&amp;quot;)&lt;br /&gt;
 tk.eval (&amp;quot;source $env(GISBASE)/etc/gui.tcl&amp;quot;)&lt;br /&gt;
 # Here you could do various things to change what the gui does&lt;br /&gt;
 # See gui.tcl and README.GUI&lt;br /&gt;
 &lt;br /&gt;
 # Make a gui (per dialog)&lt;br /&gt;
 # This sets up a window for the command.&lt;br /&gt;
 # This can be different to integrate with tkinter:&lt;br /&gt;
 tk.eval ('set path &amp;quot;.dialog$dlg&amp;quot;')&lt;br /&gt;
 tk.eval ('toplevel .dialog$dlg')&lt;br /&gt;
 # Load the code for this command:&lt;br /&gt;
 fd = os.popen (&amp;quot;d.vect --tcltk&amp;quot;)&lt;br /&gt;
 gui = fd.read()&lt;br /&gt;
 # Run it&lt;br /&gt;
 tk.eval(gui)&lt;br /&gt;
 dlg = tk.eval('set dlg') # This is used later to get and set &lt;br /&gt;
 &lt;br /&gt;
 # Get the current command in the gui we just made:&lt;br /&gt;
 currentcommand = tk.eval (&amp;quot;dialog_get_command &amp;quot; + dlg)&lt;br /&gt;
 &lt;br /&gt;
 # Set the command in the dialog we just made:&lt;br /&gt;
 tk.eval (&amp;quot;dialog_set_command &amp;quot; + dlg + &amp;quot; {d.vect map=roads}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* GRASS-SWIG interface http://mpa.itc.it/markus/grass61progman/swig/&lt;br /&gt;
* SWIG http://www.swig.org/&lt;br /&gt;
* SIP (C/C++ bindings generator) http://directory.fsf.org/all/Python-SIP.html&lt;br /&gt;
* Python and GDAL/OGR:&lt;br /&gt;
** [http://mapserver.gis.umn.edu/community/conferences/MUM3/workshop/python Open Source Python GIS Hacks Mum'03]&lt;br /&gt;
** http://hobu.biz/software/OSGIS_Hacks - Python OSGIS Hacks '05&lt;br /&gt;
** http://zcologia.com/news/categorylist_html?cat_id=8&lt;br /&gt;
** http://www.perrygeo.net/wordpress/?p=4&lt;br /&gt;
* Python bindings to PROJ:&lt;br /&gt;
** http://www.cdc.noaa.gov/people/jeffrey.s.whitaker/python/pyproj.html&lt;br /&gt;
* Other external projects&lt;br /&gt;
** Scientific Python: http://www.scipy.org/&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Cedricshock</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Python&amp;diff=2134</id>
		<title>GRASS and Python</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Python&amp;diff=2134"/>
		<updated>2006-07-15T20:36:06Z</updated>

		<summary type="html">&lt;p&gt;⚠️Cedricshock: Added useing gui in python example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Python extensions for GRASS GIS==&lt;br /&gt;
&lt;br /&gt;
===Python-SWIG-GRASS interface===&lt;br /&gt;
There is a prototype GRASS-SWIG interface available (thanks to Sajith VK), find it in GRASS 6-CVS: swig/python/&lt;br /&gt;
&lt;br /&gt;
Background: [http://www.swig.org SWIG] (Simplified Wrapper and Interface Generator) is: &lt;br /&gt;
&lt;br /&gt;
* A compiler that turns ANSI C/C++ declarations into scripting language interfaces.&lt;br /&gt;
* Completely automated (produces a fully working Python extension module). &lt;br /&gt;
* Language neutral. SWIG can also target Tcl, Perl, Guile, MATLAB, etc... &lt;br /&gt;
* Attempts to eliminate the tedium of writing extension modules.&lt;br /&gt;
&lt;br /&gt;
'''TODO''': Implement modules support in a Python class using --interface-description and a Python-XML parser. This should be a generic class with module's name as parameter, returning back an object which describes the module (description, flags, parameters, status of not/required). See [http://freegis.org/cgi-bin/viewcvs.cgi/grass6/gui/wxpython/ GRASS 6 wxPython interface] for inspiration. Important is to auto-generate the GRASS-Python class at compile time with a Python script.&lt;br /&gt;
&lt;br /&gt;
=== Python-GRASS add-ons ===&lt;br /&gt;
&lt;br /&gt;
Stand-alone addons:&lt;br /&gt;
&lt;br /&gt;
# Jáchym Čepický's G-ps.map, a GUI to typeset printable maps with ps.map (http://les-ejk.cz/?cat=gpsmap)&lt;br /&gt;
# Jáchym Čepický's v.pydigit, a GUI to v.edit (http://les-ejk.cz/?cat=vpydigit)&lt;br /&gt;
# Jáchym Čepický's PyWPS, GRASS-Web Processing Service (http://les-ejk.cz/?cat=pywps)&lt;br /&gt;
&lt;br /&gt;
=== Using Grass gui.tcl in python ===&lt;br /&gt;
&lt;br /&gt;
Here is some example code to use the grass automatically generated guis in python code. This could (should) all be bundled up and abstracted away so that the implementation can be replaced later.&lt;br /&gt;
&lt;br /&gt;
 import Tkinter&lt;br /&gt;
 import os&lt;br /&gt;
 &lt;br /&gt;
 # Startup (once):&lt;br /&gt;
 &lt;br /&gt;
 tk = Tkinter.Tk()&lt;br /&gt;
 tk.eval (&amp;quot;wm withdraw .&amp;quot;)&lt;br /&gt;
 tk.eval (&amp;quot;source $env(GISBASE)/etc/gui.tcl&amp;quot;)&lt;br /&gt;
 # Here you could do various things to change what the gui does&lt;br /&gt;
 # See gui.tcl and README.GUI&lt;br /&gt;
 &lt;br /&gt;
 # Make a gui (per dialog)&lt;br /&gt;
 # This sets up a window for the command.&lt;br /&gt;
 # This can be different to integrate with tkinter:&lt;br /&gt;
 tk.eval ('set path &amp;quot;.dialog$dlg&amp;quot;')&lt;br /&gt;
 tk.eval ('toplevel .dialog$dlg')&lt;br /&gt;
 # Load the code for this command:&lt;br /&gt;
 fd = os.popen (&amp;quot;d.vect --tcltk&amp;quot;)&lt;br /&gt;
 gui = fd.read()&lt;br /&gt;
 # Run it&lt;br /&gt;
 tk.eval(gui)&lt;br /&gt;
 dlg = tk.eval('set dlg') # This is used later to get and set &lt;br /&gt;
 &lt;br /&gt;
 # Get the current command in the gui we just made:&lt;br /&gt;
 currentcommand = tk.eval (&amp;quot;dialog_get_command $dlg&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 # Set the command in the dialog we just made:&lt;br /&gt;
 tk.eval (&amp;quot;dialog_set_command $dlg 'd.vect map=roads'&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* GRASS-SWIG interface http://mpa.itc.it/markus/grass61progman/swig/&lt;br /&gt;
* SWIG http://www.swig.org/&lt;br /&gt;
* SIP (C/C++ bindings generator) http://directory.fsf.org/all/Python-SIP.html&lt;br /&gt;
* Python and GDAL/OGR:&lt;br /&gt;
** [http://mapserver.gis.umn.edu/community/conferences/MUM3/workshop/python Open Source Python GIS Hacks Mum'03]&lt;br /&gt;
** http://hobu.biz/software/OSGIS_Hacks - Python OSGIS Hacks '05&lt;br /&gt;
** http://zcologia.com/news/categorylist_html?cat_id=8&lt;br /&gt;
** http://www.perrygeo.net/wordpress/?p=4&lt;br /&gt;
* Python bindings to PROJ:&lt;br /&gt;
** http://www.cdc.noaa.gov/people/jeffrey.s.whitaker/python/pyproj.html&lt;br /&gt;
* Other external projects&lt;br /&gt;
** Scientific Python: http://www.scipy.org/&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Cedricshock</name></author>
	</entry>
</feed>