I'm writing a code to open a PDF file, select the number of pages to crop, and then create a new cropped file.
Here is the code:
from easygui import *
from pyPdf import PdfFileReader, PdfFileWriter
# 1 select a inputfile
inputFileName = fileopenbox('Please choose a PDF file','', '*.pdf')
#2 total pages
inputFile = PdfFileReader(file(inputFileName, 'rb'))
totalPages = inputFile.getNumPages()
#3 Enter beginning Page
begPage = enterbox('Please choose the Beginning Page','it must a number')
while not begPage.isdigit() or begPage ==0 or int(begPage) > totalPages:
msgbox('Please enter a valid digit', '', 'ok')
begPage = enterbox('Please choose the Beginning Page','it must a number')
The thing is while testing these first steps. When I select the file and click OK, the fileopenbox
freezes, and I don't get to the next step.
If I isolate the first step or the steps 1 and 2, it works just fine, but I cannot get it working with the rest of the script (step 3).
I'm using Python 2.7.10 on my macbookPro OSX 10.9.2 and easygui 0.97