[GRASS-dev] Python scripts receiving input from the GRASS GUI?

Vaclav Petras wenzeslaus at gmail.com
Wed Aug 19 06:47:59 PDT 2015


Hi Michel,

On Thu, Aug 13, 2015 at 10:32 AM, Michel Wortmann <wortmann at pik-potsdam.de>
wrote:

> Dear Devs,
> what would be the best and least invasive way of receiving input from the
> grass GUI to use in python scripts. The following functionalities are on my
> mind:
>
> - when double-clicking a line in the dbmgr, trigger a script/function
> using the line's content as input
> - when selecting a feature in the map display, trigger a script/function
> using the query results as input
>
> I guess changing the effect of a dbmgr line double-click can only be
> changed by fiddling with the gui/wxpython/dbmgr module files. Receiving the
> select query results as input on the command line is in theory possible
> with the 'Redirect to console' option in the select pop-up, but how can I
> read the GUI console?
>
> In case someone had similar intentions and has some clues, I would
> appreciate hearing about them.
>

these are reasonable requests. I suppose this would make your module more
convenient for users to use. Unfortunately, there is no easy way. Anyway,
these are the options:

1. Create a new functionality similar to the button to select coordinates.
Module would specify option type as feature ID and when the module's GUI is
started from the main GUI, the button is associated with Map Display. User
clicks the button. Clicks in Map Display. Some query function is invoked
and result goes to the input field in module's GUI. There is already a
"template" for implementing this - the coordinates button.

2. Create a plugin system for wxGUI (thanks to Python relatively simple)
and writing a plugin. If somebody wants to do that, please contact me, I
can give you few pointers.

3. Create a new feature in GUI Command Console to start a module with
current output in console as standard input for the module. I'm not sure if
this would overcomplicate things or how this can be made actually
convenient for users, but it is en interesting option.

4. For attribute data (dbmgr), "copy and paste" the line's content can be
enough. Same for query results. For query, the copy is implemented but the
format might not be good for parsing. For dbmgr, the button to copy should
be easy to add. This seems convenient enough for user.

I suggest to first check the option number 4. The most general option is
number 2 but when implemented, it would require writing a module to do the
processing and then also a plugin for GUI to do the interaction. In this
light option number 1 seems as a good way.

Best,
Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150819/2ca4bddf/attachment.html>


More information about the grass-dev mailing list