dialogs.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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, imagery groups or other elements.
  24. """
  25. def __init__(self, parent, title=_("Choose raster map")):
  26. """!Calls super class constructor.
  27. @param parent gui parent
  28. @param title dialog window title
  29. @param id id
  30. """
  31. SimpleDialog.__init__(self, parent, title)
  32. # here is the place to determine element type
  33. self.element = gselect.Select(parent=self.panel, type='raster',
  34. size=globalvar.DIALOG_GSELECT_SIZE)
  35. self._layout()
  36. self.SetMinSize(self.GetSize())
  37. def _layout(self):
  38. """!Do layout"""
  39. self.dataSizer.Add(item=wx.StaticText(parent=self.panel,
  40. label=_("Name of raster map:")),
  41. proportion=0, flag=wx.ALL, border=1)
  42. self.dataSizer.Add(self.element, proportion=0,
  43. flag=wx.EXPAND | wx.ALL, border=1)
  44. self.panel.SetSizer(self.sizer)
  45. self.sizer.Fit(self)
  46. def GetRasterMap(self):
  47. """!Returns selected raster map"""
  48. return self.element.GetValue()