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}")
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@shockfamily.net>
Date: Sat, 15 Jul 2006 13:43:49 -0700
To: <grass-dev@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}")
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@shockfamily.net>
> Date: Sat, 15 Jul 2006 13:43:49 -0700
> To: <grass-dev@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@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: jachym.cepicky@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@gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507
Jachym Cepicky napisa?(a):
If I'm not wrong, Tk goes with standard python distribution for all
platforms
On Ubuntu python-tk is a separate package, not required when installing
python. I could safely remove it having python and python-dev still
installed.
Maciek
apt-cache show python
Suggests: python-doc, python-tk, python-profiler
on other platforms, it should be internal part. no reason for make it
internal part also on linux, where dependeces are usually solved by
packaging system
jachym
On Sun, Jul 16, 2006 at 10:03:28AM +0200, Maciej Sieczka wrote:
Jachym Cepicky napisa?(a):
> If I'm not wrong, Tk goes with standard python distribution for all
> platforms
On Ubuntu python-tk is a separate package, not required when installing
python. I could safely remove it having python and python-dev still
installed.
Maciek
_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: jachym.cepicky@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@gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507
Jachym Cepicky napisa³(a):
apt-cache show python
Suggests: python-doc, python-tk, python-profiler
on other platforms, it should be internal part. no reason for make it
internal part also on linux, where dependeces are usually solved by
packaging system
I understand. I only wanted to let know that installing python on Linux
doeasn't imply python-tk installed too.
Cheers,
Maciek
I guess I didn't phrase my question correctly. Sorry. Since all GRASS
distributions already have TclTk installed, is there any advantage to
redoing gui.tcl to work in a Tkinter environment for Python testing
purposes? Or are we better off building on the python gui module that Markus
put into the cvs?
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: Jachym Cepicky <jachym.cepicky@centrum.cz>
Date: Sun, 16 Jul 2006 09:08:22 +0200
To: Michael Barton <michael.barton@asu.edu>
Cc: Cedric Shock <cedricgrass@shockfamily.net>, <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] Using current grass gui.tcl in python programs.
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@shockfamily.net>
Date: Sat, 15 Jul 2006 13:43:49 -0700
To: <grass-dev@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@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: jachym.cepicky@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@gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507
On Sun, Jul 16, 2006 at 09:34:32AM -0700, Michael Barton wrote:
I guess I didn't phrase my question correctly. Sorry. Since all GRASS
distributions already have TclTk installed, is there any advantage to
redoing gui.tcl to work in a Tkinter environment for Python testing
purposes? Or are we better off building on the python gui module that Markus
put into the cvs?
To add confusion I didn't put a python gui module into the cvs...
I uploaded the Python-SWIG code which is intended to permit Pythonic access
to library functionality of GRASS (maybe also modules in future).
Markus
Someone (I thought it was you) added a new "wxPython" directory to gui.
Inside is "grassgui.py" which looks like a wxPython version of gui.tcl.
Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
From: Markus Neteler <neteler@itc.it>
Date: Sun, 16 Jul 2006 18:41:07 +0200
To: <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] Using current grass gui.tcl in python programs.
On Sun, Jul 16, 2006 at 09:34:32AM -0700, Michael Barton wrote:
I guess I didn't phrase my question correctly. Sorry. Since all GRASS
distributions already have TclTk installed, is there any advantage to
redoing gui.tcl to work in a Tkinter environment for Python testing
purposes? Or are we better off building on the python gui module that Markus
put into the cvs?
To add confusion I didn't put a python gui module into the cvs...
I uploaded the Python-SWIG code which is intended to permit Pythonic access
to library functionality of GRASS (maybe also modules in future).
Markus
On Sun, Jul 16, 2006 at 06:41:07PM +0200, Markus Neteler wrote:
On Sun, Jul 16, 2006 at 09:34:32AM -0700, Michael Barton wrote:
> I guess I didn't phrase my question correctly. Sorry. Since all GRASS
> distributions already have TclTk installed, is there any advantage to
> redoing gui.tcl to work in a Tkinter environment for Python testing
> purposes? Or are we better off building on the python gui module that Markus
> put into the cvs?
To add confusion I didn't put a python gui module into the cvs...
I uploaded the Python-SWIG code which is intended to permit Pythonic access
to library functionality of GRASS (maybe also modules in future).
OK, confusion on my side: I immediately forgot after the upload that
there is gui/wxpython/ as well (the old prototype slightly updated).
Markus