base.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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, parent=None, tooltip=None):
  20. """Make aligned label"""
  21. if not parent:
  22. parent = self
  23. label = StaticText(parent=parent, id=wx.ID_ANY, label=text, style=style)
  24. if tooltip:
  25. label.SetToolTip(tooltip)
  26. return label
  27. def MakeTextCtrl(self, text="", size=(100, -1), style=0, parent=None, tooltip=None):
  28. """Generic text control"""
  29. if not parent:
  30. parent = self
  31. textCtrl = TextCtrl(
  32. parent=parent, id=wx.ID_ANY, value=text, size=size, style=style
  33. )
  34. if tooltip:
  35. textCtrl.SetToolTip(tooltip)
  36. return textCtrl
  37. def MakeButton(self, text, id=wx.ID_ANY, size=(-1, -1), parent=None, tooltip=None):
  38. """Generic button"""
  39. if not parent:
  40. parent = self
  41. button = Button(parent=parent, id=id, label=text, size=size)
  42. if tooltip:
  43. button.SetToolTip(tooltip)
  44. return button
  45. def MakeCheckBox(
  46. self, text, id=wx.ID_ANY, size=(-1, -1), parent=None, tooltip=None
  47. ):
  48. """Generic checkbox"""
  49. if not parent:
  50. parent = self
  51. chbox = CheckBox(parent=parent, id=id, label=text, size=size)
  52. if tooltip:
  53. chbox.SetToolTip(tooltip)
  54. return chbox