dialogs.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 gui_core.dialogs import SimpleDialog
  14. from gui_core import gselect
  15. from gui_core.widgets import SimpleValidator
  16. from core.gcmd import GMessage
  17. class SwipeMapDialog(SimpleDialog):
  18. """!Dialog used to select raster maps"""
  19. def __init__(self, parent, title = _("Select raster maps"), first = None, second = None):
  20. SimpleDialog.__init__(self, parent, title)
  21. self.element1 = gselect.Select(parent = self.panel, type = 'raster',
  22. size = globalvar.DIALOG_GSELECT_SIZE,
  23. validator = SimpleValidator(callback = self.ValidatorCallback))
  24. self.element2 = gselect.Select(parent = self.panel, type = 'raster',
  25. size = globalvar.DIALOG_GSELECT_SIZE,
  26. validator = SimpleValidator(callback = self.ValidatorCallback))
  27. self.element1.SetFocus()
  28. if first:
  29. self.element1.SetValue(first)
  30. if second:
  31. self.element2.SetValue(second)
  32. self._layout()
  33. self.SetMinSize(self.GetSize())
  34. def _layout(self):
  35. """!Do layout"""
  36. self.dataSizer.Add(wx.StaticText(self.panel, id = wx.ID_ANY,
  37. label = _("Name of top/left raster map:")),
  38. proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)
  39. self.dataSizer.Add(self.element1, proportion = 0,
  40. flag = wx.EXPAND | wx.ALL, border = 1)
  41. self.dataSizer.Add(wx.StaticText(parent = self.panel, id = wx.ID_ANY,
  42. label = _("Name of bottom/right raster map:")), proportion = 0,
  43. flag = wx.EXPAND | wx.ALL, border = 1)
  44. self.dataSizer.Add(self.element2, proportion = 0,
  45. flag = wx.EXPAND | wx.ALL, border = 1)
  46. self.panel.SetSizer(self.sizer)
  47. self.sizer.Fit(self)
  48. def ValidatorCallback(self, win):
  49. if win == self.element1.GetTextCtrl():
  50. GMessage(parent = self, message = _("Name of the first map is missing."))
  51. else:
  52. GMessage(parent = self, message = _("Name of the second map is missing."))
  53. def GetValues(self):
  54. """!Get raster maps"""
  55. return (self.element1.GetValue(), self.element2.GetValue())