| 1 |
Motivation |
| 2 |
---------- |
| 3 |
Example Tool should help new GRASS GUI programmers who are interested in |
| 4 |
adding or improving GRASS functionality or writing GRASS GUI-based |
| 5 |
application for their own purposes. |
| 6 |
|
| 7 |
How to use Example Tool |
| 8 |
----------------------- |
| 9 |
Example Tool is a simple template for applications which are |
| 10 |
supposed to display maps and make computations using GRASS modules. |
| 11 |
It covers several often occurring tasks. It can be helpful for all |
| 12 |
new developers who are interested in wxGUI programming. |
| 13 |
Run Example Tool, have a look at wxGUI.Example.html and than |
| 14 |
look at the source code to see how it works. |
| 15 |
|
| 16 |
Run Example Tool |
| 17 |
---------------- |
| 18 |
To run Example Tool can run as a standalone application (in GRASS environment) |
| 19 |
or it can be launched from the console. |
| 20 |
|
| 21 |
1. Go to GRASS root directory |
| 22 |
|
| 23 |
2. Copy directory ./doc/examples/gui/wxpython to ./gui/wxpython |
| 24 |
|
| 25 |
3. Edit ./gui/wxpython/Makefile: |
| 26 |
|
| 27 |
SUBDIRS: Add example |
| 28 |
SRCFILES: Add example/*py |
| 29 |
PYDSTDIRS: Add example |
| 30 |
|
| 31 |
4. Run make (in ./gui/wxpython) |
| 32 |
|
| 33 |
Now you can start the application by running |
| 34 |
|
| 35 |
$ g.gui.example |
| 36 |
|
| 37 |
from terminal or wxGUI command console. Try also g.gui.example --help. |
| 38 |
|
| 39 |
If you want to access Example Tool from Layer Manager menu, there are |
| 40 |
a few more things to be done. |
| 41 |
|
| 42 |
5. Edit ./gui/wxpython/xml/menudata.xml. Add following code to appropriate place: |
| 43 |
|
| 44 |
<menuitem> |
| 45 |
<label>Example</label> |
| 46 |
<help>Example help (for statusbar)</help> |
| 47 |
<keywords>raster</keywords> |
| 48 |
<handler>OnExample</handler> |
| 49 |
</menuitem> |
| 50 |
|
| 51 |
6. Add following event handler to class GMFrame in ./gui/wxpython/lmgr/frame.py: |
| 52 |
|
| 53 |
def OnExample(self, event): |
| 54 |
"""!Launch ExampleTool""" |
| 55 |
from example.frame import ExampleMapDisplay |
| 56 |
|
| 57 |
frame = wx.Frame( |
| 58 |
parent=None, size=globalvar.MAP_WINDOW_SIZE, title=_("Example Tool") |
| 59 |
) |
| 60 |
win = ExampleMapDisplay(parent=frame, giface=self._giface) |
| 61 |
win.CentreOnScreen() |
| 62 |
|
| 63 |
win.Show() |
| 64 |
|
| 65 |
7. Run make again. |
| 66 |
|
| 67 |
|
| 68 |
Note |
| 69 |
---- |
| 70 |
Feel free to improve Example Tool or suggest possible improvements. |