[GRASS-dev] Using current grass gui.tcl in python programs.

Jachym Cepicky jachym.cepicky at centrum.cz
Sun Jul 16 03:08:22 EDT 2006


If I'm not wrong, Tk goes with standard python distribution for all
platforms

jachym

On Sat, Jul 15, 2006 at 05:39:25PM -0700, Michael Barton wrote:
> Thanks Cedric.
> 
> Good to see you back.
> 
> Doesn't Tkinter require TclTk to be installed? If so, is there an advantage
> to having gui.tcl run under Python/Tkinter vs. Wish as it does now? That is,
> the wxPython prototype I'm working on can launch a GRASS command and it's
> TclTk gui. Of course this means I'm running part of the UI under TclTk and
> part under wxPython at the moment. Does Tkinter change this?
> 
> Michael
> __________________________________________
> Michael Barton, Professor of Anthropology
> School of Human Evolution & Social Change
> Center for Social Dynamics & Complexity
> Arizona State University
> 
> phone: 480-965-6213
> fax: 480-965-7671
> www: http://www.public.asu.edu/~cmbarton
> 
> 
> 
> > From: Cedric Shock <cedricgrass at shockfamily.net>
> > Date: Sat, 15 Jul 2006 13:43:49 -0700
> > To: <grass-dev at grass.itc.it>
> > Subject: [GRASS-dev] Using current grass gui.tcl in python programs.
> > 
> > Hi,
> > 
> > This might be a quick way to get up and running with playing with python
> > development. It's fairly easy to use the current gui.tcl in python. Here's an
> > example (copy / paste into python run in grass). This could all be bundled up
> > and abstracted away to be more useful. I also stuck this snippit on the wiki
> > at http://grass.gdf-hannover.de/wiki/GRASS_and_Python , so if you make
> > improvements please share them here and there.
> > 
> > --Cedric
> > 
> > import Tkinter
> > import os
> > 
> > # Startup (onde):
> > 
> > tk = Tkinter.Tk()
> > tk.eval ("wm withdraw .")
> > tk.eval ("source $env(GISBASE)/etc/gui.tcl")
> > # Here you could do various things to change what the gui does
> > # See gui.tcl and README.GUI
> > 
> > # Make a gui (per dialog)
> > # This sets up a window for the command.
> > # This can be different to integrate with tkinter:
> > tk.eval ('set path ".dialog$dlg"')
> > tk.eval ('toplevel .dialog$dlg')
> > # Load the code for this command:
> > fd = os.popen ("d.vect --tcltk")
> > gui = fd.read()
> > # Run it
> > tk.eval(gui)
> > dlg = tk.eval('set dlg') # This is used later to get and set
> > 
> > # Get the current command in the gui we just made:
> > currentcommand = tk.eval ("dialog_get_command " + dlg)
> > 
> > # Set the command in the dialog we just made:
> > tk.eval ("dialog_set_command " + dlg + " {d.vect map=roads}")
> > 
> > 
> 
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev

-- 
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------   
OFFICE:                                     
GDF-Hannover
Mengendamm 16d
30177 Hannover
Germany
e-mail: cepicky at gdf-hannover.de
URL:    http://gdf-hannover.de
Tel.:   +49 511-39088507
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20060716/ccc31e86/attachment.bin


More information about the grass-dev mailing list