Rev 6456 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1004 | subik | 1 | #!/usr/bin/env python2.3 |
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import sys |
||
5 | |||
6 | try: |
||
7 | # Please do not use 'from scribus import *' . If you must use a 'from import', |
||
8 | # Do so _after_ the 'import scribus' and only import the names you need, such |
||
9 | # as commonly used constants. |
||
10 | import scribus |
||
11 | except ImportError,err: |
||
12 | print "This Python script is written for the Scribus scripting interface." |
||
13 | print "It can only be run from within Scribus." |
||
14 | sys.exit(1) |
||
15 | |||
16 | ######################### |
||
17 | # YOUR IMPORTS GO HERE # |
||
18 | ######################### |
||
19 | |||
20 | def main(argv): |
||
21 | """This is a documentation string. Write a description of what your code |
||
22 | does here. You should generally put documentation strings ("docstrings") |
||
23 | on all your Python functions.""" |
||
24 | ######################### |
||
25 | # YOUR CODE GOES HERE # |
||
26 | ######################### |
||
27 | pass # <--- Delete this line |
||
28 | |||
29 | def main_wrapper(argv): |
||
30 | """The main_wrapper() function disables redrawing, sets a sensible generic |
||
31 | status bar message, and optionally sets up the progress bar. It then runs |
||
32 | the main() function. Once everything finishes it cleans up after the main() |
||
33 | function, making sure everything is sane before the script terminates.""" |
||
34 | try: |
||
35 | scribus.statusMessage("Running script...") |
||
36 | scribus.progressReset() |
||
37 | main(argv) |
||
38 | finally: |
||
39 | # Exit neatly even if the script terminated with an exception, |
||
40 | # so we leave the progress bar and status bar blank and make sure |
||
41 | # drawing is enabled. |
||
42 | if scribus.haveDoc(): |
||
43 | scribus.setRedraw(True) |
||
44 | scribus.statusMessage("") |
||
45 | scribus.progressReset() |
||
46 | |||
47 | # This code detects if the script is being run as a script, or imported as a module. |
||
48 | # It only runs main() if being run as a script. This permits you to import your script |
||
49 | # and control it manually for debugging. |
||
50 | if __name__ == '__main__': |
||
51 | main_wrapper(sys.argv) |