[Gvsig_english] jython-Console line in gvSIG... Usable at all?

Jorge Sanz jsanz at prodevelop.es
Thu Nov 22 16:03:36 CET 2007

Hi Wolfgang, 

there is a scripting intro tutorial but at this time only in Spanish :(


If you (or anyone) feel brave, you can try to download it (as it comes with nice examples) and try to "inspect" the code and the manual to learn a little bit about gvSIG scripting capabilities.

Just for fun, I will paste a simple lines to show the attributes of the first feature loaded into a view with only one vectorial layer. You can try it if you want, just open a new gvSIG view, add a shapefile (for example), open the scripting console and paste line by line. On the examples you will find how to define a GUI, use functions, etc etc. This is just dumb python code:

#import gvSIG functions
from gvsiglib import *

#get the view, the mapcontrol and the mapcontext
view = gvSIG.getActiveDocument()
mctrl = view.getMapControl()
mcon = mctrl.getMapContext()

#print the number of layers of the view
print mcon.getLayers().getLayersCount()

#get the first layer and print its name
lyr= mcon.getLayers().getLayer(0)
print lyr.getName()

#finally, get the recordset (attribute table) associated with the layer, print the number of features (rows) and print the first row
rc = lyr.getRecordset()
print rc.getRowCount()
print rc.getRow(1)

Immediately you will discover that the console has auto-completion so you can start "hackin" to go inside gvSIG classes. 

Soon we will have more infrastructure to post that kind of "source bits" and little "how-to's" to show how to accomplish scripting and general development tasks.

Best Regards
Jorge Gaspar Sanz Salinas
Ingeniero en Geodesia y Cartografía
Prodevelop S.L. - Valencia - España
Tlf.:  96.351.06.12 - Fax:   96.351.09.68 

> -----Mensaje original-----
> De: gvsig_internacional-bounces at runas.cap.gva.es [mailto:gvsig_internacional-
> bounces at runas.cap.gva.es] En nombre de Wolfgang Qual
> Enviado el: jueves, 22 de noviembre de 2007 15:29
> Para: gvsig_internacional at runas.cap.gva.es
> Asunto: Re: [Gvsig_english] jython-Console line in gvSIG... Usable at all?
> Hi Antonio,
> ok... were your trials successful? What did you do then? Examples available?
> And what about the batch processes? I am really curious. Hopefully, some
> other users (developers!) will add some more comments.
> Thanks a lot. Best,
> Wolfgang
> -------- Original-Nachricht --------
> > Datum: Thu, 22 Nov 2007 15:17:02 +0100
> > Von: Antonio Falciano <afalciano at yahoo.it>
> > An: Users and Developers mailing list
> <gvsig_internacional at runas.cap.gva.es>
> > Betreff: Re: [Gvsig_english] jython-Console line in gvSIG... Usable at all?
> > Wolfgang Qual ha scritto:
> > > Hello gvSIG-users and ~developers,
> > > just some short questions about the jython console:
> > > 1) is there any user who used the jython console (File > Scripting >
> > jython console) within gvSIG?
> > > 2) If so: for what purpose?
> >
> > Jython console is useful to test some pieces of code. I used it for
> > testing when I tried to write some script.
> >
> > > 3) Can it be used for batch processing?
> > > 4) Can it be used at all?
> > > 5) How?
> >
> > Yes, by code. But you can do batch processing easily writing directly a
> > Jython script.
> >
> > Best Regards,
> > Antonio
> > _______________________________________________
> > Gvsig_internacional mailing list
> > Gvsig_internacional at runas.cap.gva.es
> > http://runas.cap.gva.es/mailman/listinfo/gvsig_internacional
> --
> Psssst! Schon vom neuen GMX MultiMessenger gehört?
> Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
> _______________________________________________
> Gvsig_internacional mailing list
> Gvsig_internacional at runas.cap.gva.es
> http://runas.cap.gva.es/mailman/listinfo/gvsig_internacional

More information about the Gvsig_internacional mailing list