File: dialogs.py

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (71 lines) | stat: -rw-r--r-- 1,937 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""!
@package example.dialogs

@brief Dialogs used in Example tool

Classes:
 - dialogs::ExampleMapDialog

(C) 2011-2014 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.

@author Anna Petrasova <kratochanna gmail.com>
"""

import wx

# i18n is taken care of in the grass library code.
# So we need to import it before any of the GUI code.
# NOTE: in this particular case, we don't really need the grass library;
# NOTE: we import it just for the side effects of gettext.install()
import grass

from core import globalvar
from gui_core.dialogs import SimpleDialog
from gui_core import gselect


class ExampleMapDialog(SimpleDialog):
    """!Dialog for adding raster map.

    Dialog can be easily changed to enable to choose vector,
    imagery groups, or other elements.
    """

    def __init__(self, parent, title=_("Choose raster map")):
        """!Calls super class constructor.

        @param parent gui parent
        @param title dialog window title
        @param id id
        """
        SimpleDialog.__init__(self, parent, title)

        # here is the place to determine element type
        self.element = gselect.Select(
            parent=self.panel, type="raster", size=globalvar.DIALOG_GSELECT_SIZE
        )

        self._layout()

        self.SetMinSize(self.GetSize())

    def _layout(self):
        """!Do layout"""
        self.dataSizer.Add(
            wx.StaticText(parent=self.panel, label=_("Name of raster map:")),
            proportion=0,
            flag=wx.ALL,
            border=1,
        )
        self.dataSizer.Add(
            self.element, proportion=0, flag=wx.EXPAND | wx.ALL, border=1
        )
        self.panel.SetSizer(self.sizer)
        self.sizer.Fit(self)

    def GetRasterMap(self):
        """!Returns selected raster map"""
        return self.element.GetValue()