home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-gnome2-desktop / examples / gnomeprint / example_01.py next >
Encoding:
Python Source  |  2009-03-14  |  1.4 KB  |  56 lines

  1. #! /usr/bin/env python
  2. #
  3. # *  example_01.c: sample gnome-print code
  4. # *
  5. # *  This program is free software; you can redistribute it and/or
  6. # *  modify it under the terms of the GNU Library General Public License
  7. # *  as published by the Free Software Foundation; either version 2 of
  8. # *  the License, or (at your option) any later version.
  9. # *
  10. # *  This program is distributed in the hope that it will be useful,
  11. # *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # *  GNU Library General Public License for more details.
  14. # *
  15. # *  You should have received a copy of the GNU Library General Public
  16. # *  License along with this program; if not, write to the Free Software
  17. # *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # *
  19. # *  Authors:
  20. # *    Chema Celorio <chema@ximian.com>
  21. #    Python conversion:
  22. #      Gustavo J. A. M. Carneiro <gustavo@users.sf.net>
  23. # *
  24. # *  Copyright (C) 2002 Ximian Inc. and authors
  25. # *
  26. # */
  27.  
  28. #/*
  29. # * See README
  30. # */
  31. import pygtk; pygtk.require("2.0")
  32. import gnomeprint
  33.  
  34. def my_draw(gpc):
  35.     gpc.beginpage("1")
  36.  
  37.     gpc.moveto(100, 100)
  38.     gpc.lineto(200, 200)
  39.     gpc.stroke()
  40.     
  41.     gpc.showpage()
  42.  
  43. def my_print():
  44.     job = gnomeprint.Job(gnomeprint.config_default())
  45.     gpc = job.get_context()
  46.  
  47.     my_draw(gpc)
  48.  
  49.     job.close()
  50.     job.print_()
  51.  
  52.  
  53. my_print()
  54. print "Done..."
  55.  
  56.