dialogs.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """!
  2. @package mapswipe.dialogs
  3. @brief Dialogs used in Map Swipe
  4. Classes:
  5. - dialogs::SwipeMapDialog
  6. (C) 2012 by the GRASS Development Team
  7. This program is free software under the GNU General Public License
  8. (>=v2). Read the file COPYING that comes with GRASS for details.
  9. @author Anna Kratochvilova <kratochanna gmail.com>
  10. """
  11. import wx
  12. from core import globalvar
  13. from core.utils import _
  14. from gui_core.dialogs import SimpleDialog
  15. from gui_core import gselect
  16. from gui_core.widgets import SimpleValidator
  17. from core.gcmd import GMessage
  18. class SwipeMapDialog(SimpleDialog):
  19. """!Dialog used to select raster maps"""
  20. def __init__(self, parent, title = _("Select raster maps"), first = None, second = None):
  21. SimpleDialog.__init__(self, parent, title)
  22. self.element1 = gselect.Select(parent = self.panel, type = 'raster',
  23. size = globalvar.DIALOG_GSELECT_SIZE,
  24. validator = SimpleValidator(callback = self.ValidatorCallback))
  25. self.element2 = gselect.Select(parent = self.panel, type = 'raster',
  26. size = globalvar.DIALOG_GSELECT_SIZE,
  27. validator = SimpleValidator(callback = self.ValidatorCallback))
  28. self.element1.SetFocus()
  29. if first:
  30. self.element1.SetValue(first)
  31. if second:
  32. self.element2.SetValue(second)
  33. self._layout()
  34. self.SetMinSize(self.GetSize())
  35. def _layout(self):
  36. """!Do layout"""
  37. self.dataSizer.Add(wx.StaticText(self.panel, id = wx.ID_ANY,
  38. label = _("Name of top/left raster map:")),
  39. proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)
  40. self.dataSizer.Add(self.element1, proportion = 0,
  41. flag = wx.EXPAND | wx.ALL, border = 1)
  42. self.dataSizer.Add(wx.StaticText(parent = self.panel, id = wx.ID_ANY,
  43. label = _("Name of bottom/right raster map:")), proportion = 0,
  44. flag = wx.EXPAND | wx.ALL, border = 1)
  45. self.dataSizer.Add(self.element2, proportion = 0,
  46. flag = wx.EXPAND | wx.ALL, border = 1)
  47. self.panel.SetSizer(self.sizer)
  48. self.sizer.Fit(self)
  49. def ValidatorCallback(self, win):
  50. if win == self.element1.GetTextCtrl():
  51. GMessage(parent = self, message = _("Name of the first map is missing."))
  52. else:
  53. GMessage(parent = self, message = _("Name of the second map is missing."))
  54. def GetValues(self):
  55. """!Get raster maps"""
  56. return (self.element1.GetValue(), self.element2.GetValue())