~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to doc/gui/wxpython/example/toolbars.py

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""!
 
2
@package example.toolbars
 
3
 
 
4
@brief Example toolbars and icons.
 
5
 
 
6
Classes:
 
7
 - toolbars::ExampleMapToolbar
 
8
 - toolbars::ExampleMainToolbar
 
9
 - toolbars::ExampleMiscToolbar
 
10
 
 
11
(C) 2011-2014 by the GRASS Development Team
 
12
This program is free software under the GNU General Public
 
13
License (>=v2). Read the file COPYING that comes with GRASS
 
14
for details.
 
15
 
 
16
@author Anna Petrasova <kratochanna gmail.com>
 
17
"""
 
18
 
 
19
import wx
 
20
 
 
21
from gui_core.toolbars import BaseToolbar, BaseIcons
 
22
from icons.icon import MetaIcon
 
23
 
 
24
 
 
25
class ExampleMapToolbar(BaseToolbar):
 
26
    """!Map toolbar (to control map zoom and rendering)
 
27
    """
 
28
    def __init__(self, parent, toolSwitcher):
 
29
        """!Map toolbar constructor
 
30
        """
 
31
        BaseToolbar.__init__(self, parent, toolSwitcher)
 
32
 
 
33
        self.InitToolbar(self._toolbarData())
 
34
 
 
35
        # realize the toolbar
 
36
        self.Realize()
 
37
 
 
38
        self._default = self.pan
 
39
 
 
40
        for tool in (self.pan, self.zoomIn, self.zoomOut):
 
41
            self.toolSwitcher.AddToolToGroup(group='mouseUse', toolbar=self, tool=tool)
 
42
 
 
43
        self.EnableTool(self.zoomBack, False)
 
44
 
 
45
    def _toolbarData(self):
 
46
        """!Returns toolbar data (name, icon, handler)"""
 
47
        # BaseIcons are a set of often used icons. It is possible
 
48
        # to reuse icons in ./trunk/gui/icons/grass or add new ones there.
 
49
        icons = BaseIcons
 
50
        return self._getToolbarData((("displaymap", icons["display"],
 
51
                                      self.parent.OnDraw),
 
52
                                     ("rendermap", icons["render"],
 
53
                                      self.parent.OnRender),
 
54
                                     ("erase", icons["erase"],
 
55
                                      self.parent.OnErase),
 
56
                                     (None, ),  # creates separator
 
57
                                     ("pan", icons["pan"],
 
58
                                      self.parent.OnPan,
 
59
                                      wx.ITEM_CHECK),  # toggle tool
 
60
                                     ("zoomIn", icons["zoomIn"],
 
61
                                      self.parent.OnZoomIn,
 
62
                                      wx.ITEM_CHECK),
 
63
                                     ("zoomOut", icons["zoomOut"],
 
64
                                      self.parent.OnZoomOut,
 
65
                                      wx.ITEM_CHECK),
 
66
                                     (None, ),
 
67
                                     ("zoomBack", icons["zoomBack"],
 
68
                                      self.parent.OnZoomBack),
 
69
                                     ("zoomToMap", icons["zoomExtent"],
 
70
                                      self.parent.OnZoomToMap),
 
71
                                     ))
 
72
 
 
73
 
 
74
class ExampleMainToolbar(BaseToolbar):
 
75
    """!Toolbar with tools related to application functionality
 
76
    """
 
77
    def __init__(self, parent):
 
78
        """!Toolbar constructor
 
79
        """
 
80
        BaseToolbar.__init__(self, parent)
 
81
 
 
82
        self.InitToolbar(self._toolbarData())
 
83
 
 
84
        # realize the toolbar
 
85
        self.Realize()
 
86
 
 
87
    def _toolbarData(self):
 
88
        """!Toolbar data"""
 
89
        return self._getToolbarData((("addRaster", BaseIcons['addRast'],
 
90
                                      self.parent.OnSelectRaster),
 
91
                                     ))
 
92
 
 
93
 
 
94
class ExampleMiscToolbar(BaseToolbar):
 
95
    """!Toolbar with miscellaneous tools related to app
 
96
    """
 
97
    def __init__(self, parent):
 
98
        """!Toolbar constructor
 
99
        """
 
100
        BaseToolbar.__init__(self, parent)
 
101
 
 
102
        self.InitToolbar(self._toolbarData())
 
103
        # realize the toolbar
 
104
        self.Realize()
 
105
 
 
106
    def _toolbarData(self):
 
107
        """!Toolbar data"""
 
108
        icons = BaseIcons
 
109
        return self._getToolbarData((("help", icons['help'],
 
110
                                      self.parent.OnHelp),
 
111
                                     ("quit", icons['quit'],
 
112
                                      self.parent.OnCloseWindow),
 
113
                                     ))