arcpy and easygui - eventloop conflict?

533
2
04-04-2011 08:27 AM
TiloBornemann
New Contributor
Dear core development team and others,

In my programm I use easygui for userinputs. When the arcpy module is imported a conflict between those two modules appears when calling easygui.choicebox(...) or easygui.multchoicebox(...) with a list longer then the guifield can show at once. Without importing arcpy, easygui works fine.

download easygui: http://easygui.sourceforge.net/download/ 

the script easygui.py has to get slightly modified: replace the two instances of "4.5i" with "10cm", then it works together with arcpy. Then copy it into the python2.6/lib/side-package folder

When you execute this script, you will see the conflict:

--------------------

import easygui
import arcpy
posNameChar = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
           'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
           'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
           'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
           '1','2','3','4','5','6','7','8','9','0']
easygui.choicebox(msg='', title='', choices=(posNameChar))

----------------------------

Traceback:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 2813, in set
    self.tk.call((self._w, 'set') + args)
TclError: expected floating-point number but got "0,129032"



The number in the Traceback seems to be the position of the scrollbar, where somehow a comma has replaced the point. ???

Scrolling is still possible by mousewheel or keyboard. The scrollbar doesn't work which isn't a big Problem, but Its not nice to have Errormessages shown in the console all the time 😉

The developer of easygui assumes a Tkinter event-loop conflict as the root of this problem which supposedly goes deeper than the "4.5i" problem. But he doesn't have arcpy to check, if he is right and to develope a fix for easygui.

Does someone have any ideas how to fix this or where the problem might be located and does someone know if just importing arcpy opens an tkinter event-loop?



thanks,

Tilo
Tags (2)
0 Kudos
2 Replies
JasonScheirer
Occasional Contributor III
I don't think this is an event loop problem at all, no even loop is spun up just by importing arcpy (however, there is an event loop running in ArcMap and friends that WILL conflict with the easygui event loop). This looks like a locale issue -- try setting your locale to English - US in ArcGIS administrator under the Advanced... button and see if this still is an issue. If so, try using python's locale module to reset the locale to en_US after importing arcpy.
0 Kudos
TiloBornemann
New Contributor
Jason,

import locale
locale.setlocale(locale.LC_ALL, 'english_us')

solved the problem. Thanks a lot!

Tilo
0 Kudos