dialogs.py 1.7 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 ElementDialog, GroupDialog
  15. from gui_core import gselect
  16. class ExampleMapDialog(ElementDialog):
  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. ElementDialog.__init__(self, parent, title, label = _("Name of raster map:"))
  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.PostInit()
  31. self.__Layout()
  32. self.SetMinSize(self.GetSize())
  33. def __Layout(self):
  34. """!Do layout"""
  35. self.dataSizer.Add(item = self.element, proportion = 0,
  36. flag = wx.EXPAND | wx.ALL, border = 5)
  37. self.panel.SetSizer(self.sizer)
  38. self.sizer.Fit(self)
  39. def GetRasterMap(self):
  40. """!Returns selected raster map"""
  41. return self.GetElement()