toolbars.py 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. """
  2. @package gmodeler.toolbars
  3. @brief wxGUI Graphical Modeler toolbars classes
  4. Classes:
  5. - toolbars::ModelerToolbar
  6. (C) 2010-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 Martin Landa <landa.martin gmail.com>
  10. """
  11. import sys
  12. from gui_core.toolbars import BaseToolbar, BaseIcons
  13. from icons.icon import MetaIcon
  14. class ModelerToolbar(BaseToolbar):
  15. """Graphical modeler toolbaro (see gmodeler.py)"""
  16. def __init__(self, parent):
  17. BaseToolbar.__init__(self, parent)
  18. # workaround for http://trac.wxwidgets.org/ticket/13888
  19. if sys.platform == "darwin":
  20. parent.SetToolBar(self)
  21. self.InitToolbar(self._toolbarData())
  22. # realize the toolbar
  23. self.Realize()
  24. def _toolbarData(self):
  25. """Toolbar data"""
  26. icons = {
  27. "new": MetaIcon(img="create", label=_("Create new model (Ctrl+N)")),
  28. "open": MetaIcon(img="open", label=_("Load model from file (Ctrl+O)")),
  29. "save": MetaIcon(
  30. img="save", label=_("Save current model to file (Ctrl+S)")
  31. ),
  32. "toImage": MetaIcon(img="image-export", label=_("Export model to image")),
  33. "toPython": MetaIcon(
  34. img="python-export", label=_("Export model to Python script")
  35. ),
  36. "actionAdd": MetaIcon(
  37. img="module-add", label=_("Add command (GRASS module) to model")
  38. ),
  39. "dataAdd": MetaIcon(img="data-add", label=_("Add data to model")),
  40. "relation": MetaIcon(
  41. img="relation-create",
  42. label=_("Manually define relation between data and commands"),
  43. ),
  44. "loop": MetaIcon(img="loop-add", label=_("Add loop/series to model")),
  45. "comment": MetaIcon(img="label-add", label=_("Add comment to model")),
  46. "run": MetaIcon(img="execute", label=_("Run model")),
  47. "validate": MetaIcon(img="check", label=_("Validate model")),
  48. "settings": BaseIcons["settings"].SetLabel(_("Modeler settings")),
  49. "properties": MetaIcon(img="options", label=_("Show model properties")),
  50. "variables": MetaIcon(
  51. img="modeler-variables", label=_("Manage model variables")
  52. ),
  53. "redraw": MetaIcon(img="redraw", label=_("Redraw model canvas")),
  54. "quit": BaseIcons["quit"].SetLabel(_("Quit Graphical Modeler")),
  55. }
  56. return self._getToolbarData(
  57. (
  58. ("new", icons["new"], self.parent.OnModelNew),
  59. ("open", icons["open"], self.parent.OnModelOpen),
  60. ("save", icons["save"], self.parent.OnModelSave),
  61. ("image", icons["toImage"], self.parent.OnExportImage),
  62. ("python", icons["toPython"], self.parent.OnExportPython),
  63. (None,),
  64. ("action", icons["actionAdd"], self.parent.OnAddAction),
  65. ("data", icons["dataAdd"], self.parent.OnAddData),
  66. ("relation", icons["relation"], self.parent.OnDefineRelation),
  67. ("loop", icons["loop"], self.parent.OnDefineLoop),
  68. ("comment", icons["comment"], self.parent.OnAddComment),
  69. (None,),
  70. ("redraw", icons["redraw"], self.parent.OnCanvasRefresh),
  71. ("validate", icons["validate"], self.parent.OnValidateModel),
  72. ("run", icons["run"], self.parent.OnRunModel),
  73. (None,),
  74. ("variables", icons["variables"], self.parent.OnVariables),
  75. ("settings", icons["settings"], self.parent.OnPreferences),
  76. ("help", BaseIcons["help"], self.parent.OnHelp),
  77. (None,),
  78. ("quit", icons["quit"], self.parent.OnCloseWindow),
  79. )
  80. )