g.gui.gmodeler.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: g.gui.gmodeler
  5. # AUTHOR(S): Martin Landa <landa.martin gmail.com>
  6. # PURPOSE: Graphical Modeler to create, edit, and manage models
  7. # COPYRIGHT: (C) 2010-2012 by Martin Landa, and the GRASS Development Team
  8. #
  9. # This program is free software; you can 1redistribute it and/or
  10. # modify it under the terms of the GNU General Public License as
  11. # published by the Free Software Foundation; either version 2 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # General Public License for more details.
  18. #
  19. ############################################################################
  20. #%module
  21. #% label: Graphical Modeler.
  22. #% description: Allows to interactively create, edit and manage models.
  23. #% keywords: general
  24. #% keywords: GUI
  25. #% keywords: graphical modeler
  26. #% keywords: workflow
  27. #%end
  28. #%option G_OPT_F_INPUT
  29. #% key: file
  30. #% description: Name of model file to be loaded
  31. #% key_desc: name.gxm
  32. #% required: no
  33. #% guisection: Model
  34. #%end
  35. import os
  36. import sys
  37. import wx
  38. import gettext
  39. import grass.script as grass
  40. gui_wx_path = os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython')
  41. if gui_wx_path not in sys.path:
  42. sys.path.append(gui_wx_path)
  43. from core.giface import StandaloneGrassInterface
  44. from core.globalvar import CheckWxVersion
  45. from gmodeler.frame import ModelFrame
  46. def main():
  47. import gettext
  48. gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
  49. app = wx.PySimpleApp()
  50. if not CheckWxVersion([2, 9]):
  51. wx.InitAllImageHandlers()
  52. frame = ModelFrame(parent = None, giface = StandaloneGrassInterface())
  53. if options['file']:
  54. frame.LoadModelFile(options['file'])
  55. frame.Show()
  56. app.MainLoop()
  57. if __name__ == "__main__":
  58. options, flags = grass.parser()
  59. main()