toolbars.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 GRASS tool (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"],
  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. "help": BaseIcons["help"],
  55. "quit": BaseIcons["quit"],
  56. }
  57. return self._getToolbarData(
  58. (
  59. (
  60. ("new", icons["new"].label.rsplit(" ", 1)[0]),
  61. icons["new"],
  62. self.parent.OnModelNew,
  63. ),
  64. (
  65. ("open", icons["open"].label.rsplit(" ", 1)[0]),
  66. icons["open"],
  67. self.parent.OnModelOpen,
  68. ),
  69. (
  70. ("save", icons["save"].label.rsplit(" ", 1)[0]),
  71. icons["save"],
  72. self.parent.OnModelSave,
  73. ),
  74. (
  75. ("image", icons["toImage"].label.rsplit(" ", 1)[0]),
  76. icons["toImage"],
  77. self.parent.OnExportImage,
  78. ),
  79. (
  80. ("python", icons["toPython"].label),
  81. icons["toPython"],
  82. self.parent.OnExportPython,
  83. ),
  84. (None,),
  85. (
  86. ("action", icons["actionAdd"].label),
  87. icons["actionAdd"],
  88. self.parent.OnAddAction,
  89. ),
  90. (
  91. ("data", icons["dataAdd"].label),
  92. icons["dataAdd"],
  93. self.parent.OnAddData,
  94. ),
  95. (
  96. ("relation", icons["relation"].label),
  97. icons["relation"],
  98. self.parent.OnDefineRelation,
  99. ),
  100. (
  101. ("loop", icons["loop"].label),
  102. icons["loop"],
  103. self.parent.OnDefineLoop,
  104. ),
  105. (
  106. ("comment", icons["comment"].label),
  107. icons["comment"],
  108. self.parent.OnAddComment,
  109. ),
  110. (None,),
  111. (
  112. ("redraw", icons["redraw"].label),
  113. icons["redraw"],
  114. self.parent.OnCanvasRefresh,
  115. ),
  116. (
  117. ("validate", icons["validate"].label),
  118. icons["validate"],
  119. self.parent.OnValidateModel,
  120. ),
  121. (
  122. ("run", icons["run"].label),
  123. icons["run"],
  124. self.parent.OnRunModel,
  125. ),
  126. (None,),
  127. (
  128. ("variables", icons["variables"].label),
  129. icons["variables"],
  130. self.parent.OnVariables,
  131. ),
  132. (
  133. ("settings", icons["settings"].label),
  134. icons["settings"],
  135. self.parent.OnPreferences,
  136. ),
  137. (
  138. ("help", icons["help"].label),
  139. icons["help"],
  140. self.parent.OnHelp,
  141. ),
  142. (None,),
  143. (
  144. ("quit", icons["quit"].label),
  145. icons["quit"],
  146. self.parent.OnCloseWindow,
  147. ),
  148. )
  149. )