dialogs.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. """!
  2. @package example.dialogs
  3. @brief Dialogs used in Example tool
  4. Classes:
  5. - dialogs::ExampleMapDialog
  6. (C) 2011-2014 by the GRASS Development Team
  7. This program is free software under the GNU General Public
  8. License (>=v2). Read the file COPYING that comes with GRASS
  9. for details.
  10. @author Anna Petrasova <kratochanna gmail.com>
  11. """
  12. import wx
  13. # i18n is taken care of in the grass library code.
  14. # So we need to import it before any of the GUI code.
  15. # NOTE: in this particular case, we don't really need the grass library;
  16. # NOTE: we import it just for the side effects of gettext.install()
  17. import grass
  18. from core import globalvar
  19. from gui_core.dialogs import SimpleDialog
  20. from gui_core import gselect
  21. class ExampleMapDialog(SimpleDialog):
  22. """!Dialog for adding raster map.
  23. Dialog can be easily changed to enable to choose vector,
  24. imagery groups, or other elements.
  25. """
  26. def __init__(self, parent, title=_("Choose raster map")):
  27. """!Calls super class constructor.
  28. @param parent gui parent
  29. @param title dialog window title
  30. @param id id
  31. """
  32. SimpleDialog.__init__(self, parent, title)
  33. # here is the place to determine element type
  34. self.element = gselect.Select(
  35. parent=self.panel, type="raster", size=globalvar.DIALOG_GSELECT_SIZE
  36. )
  37. self._layout()
  38. self.SetMinSize(self.GetSize())
  39. def _layout(self):
  40. """!Do layout"""
  41. self.dataSizer.Add(
  42. item=wx.StaticText(parent=self.panel, label=_("Name of raster map:")),
  43. proportion=0,
  44. flag=wx.ALL,
  45. border=1,
  46. )
  47. self.dataSizer.Add(
  48. self.element, proportion=0, flag=wx.EXPAND | wx.ALL, border=1
  49. )
  50. self.panel.SetSizer(self.sizer)
  51. self.sizer.Fit(self)
  52. def GetRasterMap(self):
  53. """!Returns selected raster map"""
  54. return self.element.GetValue()