#24 menu and problems with unicode

None
closed-out-of-date
nobody
None
5
2013-09-26
2005-05-23
Anonymous
No

Hi,
when using Pmw.Menu together with unicode locale I
found the following problem.

self.menu.addmenuitem( menu, 'command', label=label,
accelerator=accelerator, statusHelp=help, command=command)
File
"/mnt/bkchem.img/bkchem-dev/bkchem--beda--0.1.0/bkchem/Pmw.py",
line 3901, in addmenuitem
self._addHotkeyToOptions(menuName, kw, 'label',
traverseSpec)
File
"/mnt/bkchem.img/bkchem-dev/bkchem--beda--0.1.0/bkchem/Pmw.py",
line 3950, in _addHotkeyToOptions
label = str(menu.entrycget(item, textKey))
UnicodeEncodeError: 'ascii' codec can't encode
character u'\xfd' in position 3: ordinal not in range(128)

The call to str() crashes on non ascii characters. This
bug is simply solved by replacing the str() call with
unicode().
Diff agains Pmw 1.2 follows:

3936c3936
< label =
unicode(menubutton.cget(textKey))
---
> label =
str(menubutton.cget(textKey))
3950c3950
< label =
unicode(menu.entrycget(item, textKey))
---
> label =
str(menu.entrycget(item, textKey))

Cheers
Beda Kosata (beda@zirael.org)

Discussion

  • Adrian
    Adrian
    2013-09-26

    • status: open --> closed-out-of-date
    • Group: -->