home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / gimp / 2.0 / python / gimpplugin.py < prev    next >
Encoding:
Python Source  |  2006-07-10  |  2.0 KB  |  56 lines

  1. #   Gimp-Python - allows the writing of Gimp plugins in Python.
  2. #   Copyright (C) 1997  James Henstridge <james@daa.com.au>
  3. #
  4. #    This program is free software; you can redistribute it and/or modify
  5. #   it under the terms of the GNU General Public License as published by
  6. #   the Free Software Foundation; either version 2 of the License, or
  7. #   (at your option) any later version.
  8. #
  9. #   This program is distributed in the hope that it will be useful,
  10. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. #   GNU General Public License for more details.
  13. #
  14. #   You should have received a copy of the GNU General Public License
  15. #   along with this program; if not, write to the Free Software
  16. #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  
  18. #   plugin.py -- helper for writing gimp plugins
  19. #     Copyright (C) 1997, James Henstridge.
  20. #
  21. # This is a small wrapper that makes plugins look like an object class that
  22. # you can derive to create your plugin.  With this wrapper, you are pretty
  23. # much responsible for doing everything (checking run_mode, gui, etc).  If
  24. # you want to write a quick plugin, you probably want the gimpfu module.
  25. #
  26. # A plugin using this module would look something like this:
  27. #
  28. #   import gimp, gimpplugin
  29. #   pdb = gimp.pdb
  30. #   class myplugin(gimpplugin.plugin):
  31. #           def query(self):
  32. #                   gimp.install_procedure("plug_in_mine", ...)
  33. #           def plug_in_mine(self, par1, par2, par3,...):
  34. #                   do_something()
  35. #
  36. #   if __name__ == '__main__': myplugin().start()
  37.  
  38. import gimp
  39.  
  40. class plugin:
  41.     def start(self):
  42.         gimp.main(self.init, self.quit, self.query, self._run)
  43.     def init(self):
  44.         pass
  45.     def quit(self):
  46.         pass
  47.     def query(self):
  48.         pass
  49.     def _run(self, name, params):
  50.         if hasattr(self, name):
  51.             apply(getattr(self, name), params)
  52.         else:
  53.             raise AttributeError, name
  54.  
  55. if __name__ == '__main__': plugin().start()
  56.