robertlugg / easygui

easygui for Python
http://easygui.readthedocs.org/en/master/
BSD 3-Clause "New" or "Revised" License
458 stars 115 forks source link

choicebox not working under Python 3.10.1 #191

Closed ingski closed 2 years ago

ingski commented 2 years ago

import easygui easygui.choicebox("Text", choices = ['a', 'b'])

results in Error:

Traceback (most recent call last): File "./dummy.py", line 2, in easygui.choicebox("Text", choices = ['a', 'b']) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/easygui/boxes/choice_box.py", line 38, in choicebox mb = ChoiceBox(msg, title, choices, preselect=preselect, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/easygui/boxes/choice_box.py", line 123, in init preselect_list = make_list_or_none(preselect, cast_type=int) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/easygui/boxes/choice_box.py", line 95, in make_list_or_none if not isinstance(obj, collections.Sequence): AttributeError: module 'collections' has no attribute 'Sequence'

BeppeC commented 2 years ago

The error is due because staritng from Python 3.7 Sequnce has been moved to collections.abc I fixed on mine adding in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/easygui/boxes/choice_box.py after import declarations

try:
    collectionsAbc = collections.abc
except AttributeError:
    collectionsAbc = collections

and then replacing in the file collections with collectionsAbc

I don't know if it is the best solution but it worked with me

ingski commented 2 years ago

I now fixed it by replacing in the file collections with collections.abc

tirkarthi commented 2 years ago

Seems to have been fixed in https://github.com/robertlugg/easygui/commit/a3391a3d896c88992c65233ae1819262b76c261a

zadacka commented 2 years ago

Yep, this one should be fixed now. Thank you for reporting it!