g.gui.dbmgr.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: g.gui.dbmgr
  5. # AUTHOR(S): Martin Landa <landa.martin gmail.com>
  6. # PURPOSE: Attribute Table Manager
  7. # COPYRIGHT: (C) 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. #% description: Launches graphical attribute table manager.
  22. #% keywords: general
  23. #% keywords: GUI
  24. #% keywords: attribute table
  25. #% keywords: database
  26. #%end
  27. #%option G_OPT_V_MAP
  28. #%end
  29. import os
  30. import sys
  31. import wx
  32. import gettext
  33. gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
  34. import grass.script as grass
  35. gui_wx_path = os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython')
  36. if gui_wx_path not in sys.path:
  37. sys.path.append(gui_wx_path)
  38. from dbmgr.manager import AttributeManager
  39. def main():
  40. mapName = grass.find_file(options['map'], element = 'vector')['fullname']
  41. if not mapName:
  42. grass.set_raise_on_error(False)
  43. grass.fatal(_("Vector map <%s> not found") % options['map'])
  44. app = wx.PySimpleApp()
  45. grass.message(_("Loading attribute data for vector map <%s>...") % mapName)
  46. f = AttributeManager(parent = None, id = wx.ID_ANY,
  47. title = "%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
  48. mapName),
  49. size = (900, 600), vectorName = mapName)
  50. f.Show()
  51. app.MainLoop()
  52. if __name__ == "__main__":
  53. options, flags = grass.parser()
  54. main()