Ruseiro
Ruseiro

Reputation: 23

Python: EasyGui freezes with fileopenbox()

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

Upvotes: 1

Views: 2709

Answers (1)

SiHa
SiHa

Reputation: 8411

Easygui uses tkinter for its gui bits.

This page says that (emphasis mine):

If you are using Python from a python.org 64-bit/32-bit Python installer for Mac OS X 10.6 and later, you should only use IDLE or tkinter with an updated third-party Tcl/Tk 8.5, like ActiveTcl 8.5 installed.

If you are using OS X 10.9 or later and a Python from a python.org 64-bit/32-bit installer, application windows may not update properly due to a Tk problem. Install the latest ActiveTcl 8.5.18.0 if possible. (Also, a critical OS X 10.9 problem that could cause Python to crash when used interactively has been fixed as of the 3.4.0, 3.3.3, and 2.7.6 installers.)

If you are using Mac OS X 10.6, do not use IDLE or Tkinter from the Apple-supplied Python 2.6.1 in Mac OS X 10.6. If possible, install and use a newer version of Python and of Tcl/Tk.

This sounds like your problem, so it looks like ActiveTcl is what you require to fix your tk problem.

Upvotes: 1

Related Questions