dialogs.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. """!
  2. @package example.dialogs
  3. @brief Dialogs used in Example tool
  4. Classes:
  5. - dialogs::ExampleMapDialog
  6. (C) 2006-2011 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 Kratochvilova <kratochanna gmail.com>
  11. """
  12. import wx
  13. from core import globalvar
  14. from gui_core.dialogs import SimpleDialog, GroupDialog
  15. from gui_core import gselect
  16. class ExampleMapDialog(SimpleDialog):
  17. """!Dialog for adding raster map.
  18. Dialog can be easily changed to enable to choose vector, imagery groups or other elements.
  19. """
  20. def __init__(self, parent, title = _("Choose raster map"), id = wx.ID_ANY):
  21. """!Calls super class constructor.
  22. @param parent gui parent
  23. @param title dialog window title
  24. @param id id
  25. """
  26. SimpleDialog.__init__(self, parent, title)
  27. # here is the place to determine element type
  28. self.element = gselect.Select(parent = self.panel, type = 'raster',
  29. size = globalvar.DIALOG_GSELECT_SIZE)
  30. self._layout()
  31. self.SetMinSize(self.GetSize())
  32. def _layout(self):
  33. """!Do layout"""
  34. self.dataSizer.Add(item = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
  35. label = _("Name of raster map:")),
  36. proportion = 0, flag = wx.ALL, border = 1)
  37. self.dataSizer.Add(self.element, proportion = 0,
  38. flag = wx.EXPAND | wx.ALL, border = 1)
  39. self.panel.SetSizer(self.sizer)
  40. self.sizer.Fit(self)
  41. def GetRasterMap(self):
  42. """!Returns selected raster map"""
  43. return self.element.GetValue()