Closed icemac closed 12 years ago
I added unicode support, check it out.
Am 09.02.2012 um 15:44 schrieb ponty:
I added unicode support, check it out.
Nice, but I found one problem: The default argument of a choice gets converted to a string, this breaks with a UnicodeError if it contains something outside ASCII:
.../psidialogs-0.0.5-py2.7.egg/psidialogs/mixins.py(25)_choice() -> args.default=str(args.default) (Pdb) l 20 args = args.copy() 21 lines = [ '[%s] %s' % x for x in zip(count(), args.choices) ] 22 args.message += '\n' + '\n'.join(lines) 23 args.message += '\nSelect:' 24 ## self.text(args) 25 -> args.default=str(args.default)
I replaced "str" with "unicode". If this works then I upload it to PYPI
Am 16.02.2012 um 14:05 schrieb ponty:
I replaced "str" with "unicode". If this works then I upload it to PYPI
Works like a charm for console backend, easygui backend breaks: If the choice options are unicode strings containing non-ASCII characters the following traceback occurrs:
File ".../psidialogs/plugins/easygui_wrapper.py", line 24, in choice return easygui.choicebox(msg=args.message, title=args.title, choices=args.choices) File ".../easygui-0.96-py2.7.egg/easygui.py", line 1017, in choicebox return choicebox(msg,title,choices) File ".../easygui-0.96-py2.7.egg/easygui.py", line 1045, in choicebox choices[index] = str(choices[index]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 10: ordinal not in range(128)
But if the choice options are UTF-8 encoded strings, easygui returns the chosen value as unicode! So it's not compatible with both backends.
Am 18.02.2012 um 10:20 schrieb ponty:
- some backends were fixed : zenity, pythondialog, easygui
- Unit tests are using unicode characters.
- Unicode characters were added to demo.py for testing. Screenshots: http://ponty.github.com/psidialogs/screen.html
Nice work! Thank you! :-D Tested it successfully with console and easygui backends.
If I call the
message
method on the console backend with unicode string containing a non-ASCII character it breaks with aUnicodeDecodeError
but for other backends (I forgot which one(s)) it is required to use unicode to prevent aUnicodeEncodeError
.Please make sure that at least unicode works for all backends (other methods have the same problem).