Dear dialog.py developer,
I'm not a python programmer but I'm just learning ;)
I believe that dialog.py's method "menu" fails if I call it with a list of strings which is encode in UTF-8 (i.e. the string contains non-ASCII characters)
What I did:
... suggestions = list(list(unicode(grepout.read(), "UTF-8"))[2:]) ...
suggestions contains a list of Unicode characters. Fine. suggestions[3] etc. can I insert in TM's document perfectly.
But:
result = dialog.menu(suggestions)
fails.
Did I something wrong or is this an issue of dialog.py?
Many thanks in advance,
--Hans
On May 29, 2008, at 11:18 AM, Hans-Jörg Bibiko wrote:
Dear dialog.py developer,
Hello.
I'm not a python programmer but I'm just learning ;)
I believe that dialog.py's method "menu" fails if I call it with a list of strings which is encode in UTF-8 (i.e. the string contains non-ASCII characters)
What I did:
... suggestions = list(list(unicode(grepout.read(), "UTF-8"))[2:]) ...
Just a tip here...
a_list[2:] returns a list, so the second list call is redundant.
suggestions contains a list of Unicode characters. Fine. suggestions[3] etc. can I insert in TM's document perfectly.
But:
result = dialog.menu(suggestions)
fails.
Did I something wrong or is this an issue of dialog.py?
dialog.py didn't support unicode. I have made a couple changes that I think should fix you're problem. Let me know if it works now!
–Alex
On 30 May 2008, at 04:58, Alex Ross wrote:
... suggestions = list(list(unicode(grepout.read(), "UTF-8"))[2:]) ...
Just a tip here...
a_list[2:] returns a list, so the second list call is redundant.
Thanks. I've already mentioned, I'm just learning python, but I thought: make assurance double sure. ;)
suggestions contains a list of Unicode characters. Fine. suggestions[3] etc. can I insert in TM's document perfectly.
But:
result = dialog.menu(suggestions)
fails.
dialog.py didn't support unicode. I have made a couple changes that I think should fix you're problem. Let me know if it works now!
Now it works brilliant. Thanks a lot. Yesterday I wrote my own routine to call tm_dialog directly, but now the code looks much more elegant :)
But one tiny thing I found in dialog.py line 14: dialog = os.path.join(support, 'bin/tm_dialog')
You bound it directly. I would suggest to use dialog = os.environ["DIALOG"] caused by the issue that we have DIALOG1 (tm_dialog) and DIALOG2 (tm_dialog2). If one calls DIALOG2 with the 'old' argument structure it switches automatically to DIALOG1. By doing so, I mean, the script is more flexible.
Once again thanks,
--Hans
On May 30, 2008, at 12:02 AM, Hans-Joerg Bibiko wrote:
On 30 May 2008, at 04:58, Alex Ross wrote:
... suggestions = list(list(unicode(grepout.read(), "UTF-8"))[2:]) ...
Just a tip here...
a_list[2:] returns a list, so the second list call is redundant.
Thanks. I've already mentioned, I'm just learning python, but I thought: make assurance double sure. ;)
suggestions contains a list of Unicode characters. Fine. suggestions[3] etc. can I insert in TM's document perfectly.
But:
result = dialog.menu(suggestions)
fails.
dialog.py didn't support unicode. I have made a couple changes that I think should fix you're problem. Let me know if it works now!
Now it works brilliant. Thanks a lot. Yesterday I wrote my own routine to call tm_dialog directly, but now the code looks much more elegant :)
But one tiny thing I found in dialog.py line 14: dialog = os.path.join(support, 'bin/tm_dialog')
You bound it directly. I would suggest to use dialog = os.environ["DIALOG"] caused by the issue that we have DIALOG1 (tm_dialog) and DIALOG2 (tm_dialog2). If one calls DIALOG2 with the 'old' argument structure it switches automatically to DIALOG1. By doing so, I mean, the script is more flexible.
Duly noted. The change is made.