|
16 | 16 | total_pages = input_file.getNumPages() |
17 | 17 |
|
18 | 18 | # let the user choose a beginning page |
19 | | -page_start = gui.enterbox("Enter the number of the first page to use:", "Where to begin?") |
| 19 | +page_start = gui.enterbox( |
| 20 | + "Enter the number of the first page to use:", "Where to begin?" |
| 21 | +) |
20 | 22 | if page_start is None: # exit on "Cancel" |
21 | 23 | exit() |
22 | 24 | # check for possible problems and try again: |
23 | 25 | # 1) input page number isn't a (non-negative) digit |
24 | 26 | # or 2) input page number is 0 |
25 | 27 | # or 3) page number is greater than total number of pages |
26 | | -while not page_start.isdigit() or page_start == "0" or int(page_start) > total_pages: |
| 28 | +while ( |
| 29 | + not page_start.isdigit() |
| 30 | + or page_start == "0" |
| 31 | + or int(page_start) > total_pages |
| 32 | +): |
27 | 33 | gui.msgbox("Please provide a valid page number.", "Whoops!") |
28 | 34 | page_start = gui.enterbox( |
29 | 35 | "Enter the number of the first page to use:", "Where to begin?" |
|
32 | 38 | exit() |
33 | 39 |
|
34 | 40 | # let the user choose an ending page |
35 | | -page_end = gui.enterbox("Enter the number of the last page to use:", "Where to end?") |
| 41 | +page_end = gui.enterbox( |
| 42 | + "Enter the number of the last page to use:", "Where to end?" |
| 43 | +) |
36 | 44 | if page_end is None: # exit on "Cancel" |
37 | 45 | exit() |
38 | 46 | # check for possible problems and try again: |
|
47 | 55 | or int(page_end) < int(page_start) |
48 | 56 | ): |
49 | 57 | gui.msgbox("Please provide a valid page number.", "Whoops!") |
50 | | - page_end = gui.enterbox("Enter the number of the last page to use:", "Where to end?") |
| 58 | + page_end = gui.enterbox( |
| 59 | + "Enter the number of the last page to use:", "Where to end?" |
| 60 | + ) |
51 | 61 | if page_end is None: # exit on "Cancel" |
52 | 62 | exit() |
53 | 63 |
|
54 | 64 | # let the user choose an output file name |
55 | 65 | output_file_name = gui.filesavebox("", "Save the trimmed PDF as...", "*.pdf") |
56 | 66 | while input_file_name == output_file_name: # cannot use same file as input |
57 | | - gui.msgbox("Cannot overwrite original file!", "Please choose another file...") |
58 | | - output_file_name = gui.filesavebox("", "Save the trimmed PDF as...", "*.pdf") |
| 67 | + gui.msgbox( |
| 68 | + "Cannot overwrite original file!", "Please choose another file..." |
| 69 | + ) |
| 70 | + output_file_name = gui.filesavebox( |
| 71 | + "", "Save the trimmed PDF as...", "*.pdf" |
| 72 | + ) |
59 | 73 | if output_file_name is None: |
60 | 74 | exit() # exit on "Cancel" |
61 | 75 |
|
|
0 commit comments