Python 3 and easygui problem

Peter Anderson peter.anderson at
Sun Feb 22 05:46:07 CET 2009

I have just installed Python 3. I have been using Tkinter and easygui 
(with Python 2.5.4) for any GUI needs. I have just started to port some 
of my existing scripts to Python 3 and discovered problems with easygui.

I was using the following script for testing:

from easygui import *
import sys

while 1:
msgbox("Hello, world!")

msg ="What is your favorite flavor?"
title = "Ice Cream Survey"
choices = ["Vanilla", "Chocolate", "Strawberry", "Rocky Road"]
choice = choicebox(msg, title, choices)

# note that we convert choice to string, in case
# the user cancelled the choice, and we got None.
msgbox("You chose: " + str(choice), "Survey Result")

msg = "Do you want to continue?"
title = "Please Confirm"
if ccbox(msg, title): # show a Continue/Cancel dialog
pass # user chose Continue
sys.exit(0) # user chose Cancel

I have changed the easygui source to Python 3 'import' and 'print' 
requirements and the initial message box in the above script displays 
fine fine. However the subsequent message boxes do not display and after 
the script completes I get the following error message:

---------- Python 3 ----------
Traceback (most recent call last):
File "", line 10, in
choice = choicebox(msg, title, choices)
File "C:\Python30\lib\site-packages\", line 703, in choicebox
return __choicebox(msg,title,choices,buttons)
File "C:\Python30\lib\site-packages\", line 824, in __choicebox
choices.sort( lambda x,y: cmp(x.lower(), y.lower())) # case-insensitive sort
TypeError: must use keyword argument for key function

Output completed (7 sec consumed)

Fixing this is a bit beyond my skills and I was wondering whether anyone 
has any thoughts.

I am happy to post a copy of my revised script.

*Peter Anderson*
There is nothing more difficult to take in hand, more perilous to 
conduct, or more uncertain in its success, than to take the lead in the 
introduction of a new order of things—Niccolo Machiavelli, /The Prince/, 
ch. 6

More information about the Python-list mailing list