""" @package gmodeler.toolbars @brief wxGUI Graphical Modeler toolbars classes Classes: - toolbars::ModelerToolbar (C) 2010-2011 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details. @author Martin Landa """ import sys from gui_core.toolbars import BaseToolbar, BaseIcons from icons.icon import MetaIcon class ModelerToolbar(BaseToolbar): """Graphical modeler toolbaro (see gmodeler.py)""" def __init__(self, parent): BaseToolbar.__init__(self, parent) # workaround for http://trac.wxwidgets.org/ticket/13888 if sys.platform == "darwin": parent.SetToolBar(self) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """Toolbar data""" icons = { "new": MetaIcon(img="create", label=_("Create new model (Ctrl+N)")), "open": MetaIcon(img="open", label=_("Load model from file (Ctrl+O)")), "save": MetaIcon( img="save", label=_("Save current model to file (Ctrl+S)") ), "toImage": MetaIcon(img="image-export", label=_("Export model to image")), "toPython": MetaIcon( img="python-export", label=_("Export model to Python script") ), "actionAdd": MetaIcon( img="module-add", label=_("Add GRASS tool (module) to model") ), "dataAdd": MetaIcon(img="data-add", label=_("Add data to model")), "relation": MetaIcon( img="relation-create", label=_("Manually define relation between data and commands"), ), "loop": MetaIcon(img="loop-add", label=_("Add loop/series to model")), "comment": MetaIcon(img="label-add", label=_("Add comment to model")), "run": MetaIcon(img="execute", label=_("Run model")), "validate": MetaIcon(img="check", label=_("Validate model")), "settings": BaseIcons["settings"], "properties": MetaIcon(img="options", label=_("Show model properties")), "variables": MetaIcon( img="modeler-variables", label=_("Manage model variables") ), "redraw": MetaIcon(img="redraw", label=_("Redraw model canvas")), "help": BaseIcons["help"], "quit": BaseIcons["quit"], } return self._getToolbarData( ( ( ("new", icons["new"].label.rsplit(" ", 1)[0]), icons["new"], self.parent.OnModelNew, ), ( ("open", icons["open"].label.rsplit(" ", 1)[0]), icons["open"], self.parent.OnModelOpen, ), ( ("save", icons["save"].label.rsplit(" ", 1)[0]), icons["save"], self.parent.OnModelSave, ), ( ("image", icons["toImage"].label.rsplit(" ", 1)[0]), icons["toImage"], self.parent.OnExportImage, ), ( ("python", icons["toPython"].label), icons["toPython"], self.parent.OnExportPython, ), (None,), ( ("action", icons["actionAdd"].label), icons["actionAdd"], self.parent.OnAddAction, ), ( ("data", icons["dataAdd"].label), icons["dataAdd"], self.parent.OnAddData, ), ( ("relation", icons["relation"].label), icons["relation"], self.parent.OnDefineRelation, ), ( ("loop", icons["loop"].label), icons["loop"], self.parent.OnDefineLoop, ), ( ("comment", icons["comment"].label), icons["comment"], self.parent.OnAddComment, ), (None,), ( ("redraw", icons["redraw"].label), icons["redraw"], self.parent.OnCanvasRefresh, ), ( ("validate", icons["validate"].label), icons["validate"], self.parent.OnValidateModel, ), ( ("run", icons["run"].label), icons["run"], self.parent.OnRunModel, ), (None,), ( ("variables", icons["variables"].label), icons["variables"], self.parent.OnVariables, ), ( ("settings", icons["settings"].label), icons["settings"], self.parent.OnPreferences, ), ( ("help", icons["help"].label), icons["help"], self.parent.OnHelp, ), (None,), ( ("quit", icons["quit"].label), icons["quit"], self.parent.OnCloseWindow, ), ) )