I am getting an error in the rs.CheckListBox() method, and it seems to be some kind of weird unicode problem.
Here is the test script:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
names=["Default","0","Existant"]
#names=["Default","0","Existant","à démolir"]
name_list=[(name,False) for name in names]
print name_list
msg="Pick an item"
CLB=rs.CheckListBox(name_list,msg)
for item in CLB:
if item[1]: print "Chosen: {}".format(item[0])
Which runs OK. Now uncomment line #7 (the one that has the list with 2 accented characters) and run it again.
It errors out with "Message: Unable to translate bytes [E0] at index 0 from specified code page to Unicode."
Now these are standard accented characters, notably typed with à = Alt+0224 and é = Alt+0233 . Normally they are accepted as long as I have the
#!/usr/bin/env python
# -*- coding: utf-8 -*-
at the top of the script. So what is going on here?
Note that the print name_list line also spits out this:
You aren’t doing anything wrong. This is an outstanding bug that I’m still trying to figure out how to fix. The CheckListBox function itself doesn’t know how to deal with strings.
Yes, you would still have to modify the CheckListBox definition in userinterface.py either with unicode() or format(). But, of course, until the error is officially fixed, a custom definition in the script will make it work everywhere.