aroberge / easygui_qt

Inspired by easygui, designed for PyQt
BSD 3-Clause "New" or "Revised" License
60 stars 18 forks source link

cast return values to standard types? #2

Closed jeremygray closed 9 years ago

jeremygray commented 9 years ago

easygui_qt looks nice. I'm playing with it in Python 2.7.8 (Anaconda 2.0.1 (x86_64)).

get_int returns a python <type 'int'>, but some of the return values are of type PyQt4.QtCore.xxx:

>>> from easygui_qt.easygui_qt import *
>>> get_list_of_choices()
[PyQt4.QtCore.QString(u'Item 8'), PyQt4.QtCore.QString(u'Item 9'), PyQt4.QtCore.QString(u'Item 0'), PyQt4.QtCore.QString(u'Item 7'), PyQt4.QtCore.QString(u'Item 3'), PyQt4.QtCore.QString(u'Item 4')]
>>>
>>> map(unicode, get_list_of_choices())
[u'Item 3', u'Item 8', u'Item 5']

Its easy enough for the user to cast the return values to standard python types, but maybe this could / should be done within easygui_qt itself (prior to returning the values). The only reason I can think of not to do that would be performance (slightly slower, more memory), but that should be negligible in the context of a gui.

aroberge commented 9 years ago

Thanks for noticing and reporting this; I had not noticed as I only printed the results.

Your suggestion of casting the values within easygui_qt itself is one that I agree with. I'll label this as a bug and will notice by reply here when I consider it to be fixed - and wait a day or so before closing it.

Note that I only do development using Python 3.4 so any unicode incompatibilties between Python 2 and Python 3 would likely not be fixed with as high a priority for Python 2.

aroberge commented 9 years ago

Documenting behaviour seen locally.

With Python 2.7.9:

>>> from easygui_qt.easygui_qt import *
>>> get_list_of_choices()
[PyQt4.QtCore.QString(u'Item 3'), PyQt4.QtCore.QString(u'Item 7')]

With Python 3.4:

>>> from easygui_qt.easygui_qt import *
>>> get_list_of_choices()
['Item 2', 'Item 3', 'Item 4', 'Item 5']
aroberge commented 9 years ago

Fixed in the repository. I plan to close this issue when a new version is uploaded to PyPI.

jeremygray commented 9 years ago

see #6