base.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. """
  2. @package location_wizard.base
  3. @brief Location wizard - base classes
  4. Classes:
  5. - base::BaseClass
  6. (C) 2007-2011 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 Michael Barton
  10. @author Jachym Cepicky
  11. @author Martin Landa <landa.martin gmail.com>
  12. """
  13. import wx
  14. from gui_core.wrap import StaticText, TextCtrl, Button, CheckBox
  15. class BaseClass(wx.Object):
  16. """Base class providing basic methods"""
  17. def __init__(self):
  18. pass
  19. def MakeLabel(self, text="", style=wx.ALIGN_LEFT,
  20. parent=None, tooltip=None):
  21. """Make aligned label"""
  22. if not parent:
  23. parent = self
  24. label = StaticText(parent=parent, id=wx.ID_ANY, label=text,
  25. style=style)
  26. if tooltip:
  27. label.SetToolTip(tooltip)
  28. return label
  29. def MakeTextCtrl(self, text='', size=(100, -1),
  30. style=0, parent=None, tooltip=None):
  31. """Generic text control"""
  32. if not parent:
  33. parent = self
  34. textCtrl = TextCtrl(parent=parent, id=wx.ID_ANY, value=text,
  35. size=size, style=style)
  36. if tooltip:
  37. textCtrl.SetToolTip(tooltip)
  38. return textCtrl
  39. def MakeButton(self, text, id=wx.ID_ANY, size=(-1, -1),
  40. parent=None, tooltip=None):
  41. """Generic button"""
  42. if not parent:
  43. parent = self
  44. button = Button(parent=parent, id=id, label=text,
  45. size=size)
  46. if tooltip:
  47. button.SetToolTip(tooltip)
  48. return button
  49. def MakeCheckBox(self, text, id=wx.ID_ANY, size=(-1, -1),
  50. parent=None, tooltip=None):
  51. """Generic checkbox"""
  52. if not parent:
  53. parent = self
  54. chbox = CheckBox(parent=parent, id=id, label=text,
  55. size=size)
  56. if tooltip:
  57. chbox.SetToolTip(tooltip)
  58. return chbox