Export to GitHub

python-ttk - issue #11

ttk treeview doesn't return unicode string


Posted on Jan 4, 2011 by Swift Bear

I am trying to adapt Guilherme's dirbrowser.py to work with unicode file and directory names. In particular, I get error messages with names that contain umlauts.

I observe that when you feed a unicode string into tk or at least the treeview widget, you get back a regular string.

What steps will reproduce the problem? This is from the populate_tree function. # This now creates a unicode pathname string dir = os.path.abspath(u'.').replace('\', '/') # Testing: yes it is unicode print 'populate_roots dir =', repr(dir) # Now we feed the unicode string into tk/ttk node = tree.insert('', 'end', text=dir, values=[dir, "directory"]) # But when we read it back out it is non-unicode: print 'populate_roots tree.set =', repr(tree.set(node, "fullpath"))

What version of the product are you using? On what operating system? Python 2.7.1, tk 8.5, Windows 7

I read that, internal to Tk, all strings are represented as unicode. Could it be that self.tk.call always converts string results to non-unicode?

Could it be there is an error in ttk:treeview?

Status: New

Labels:
Type-Defect Priority-Medium