Message308340
I think I've found another bug with Tkinter's string handling in Python 2.7.14, before it passes off to the TCL interpreter when inserting items into a ttk.Treeview widget. Specifically, it doesn't handle strings containing semi-colons very well if they are passed in via a kwarg dict.
Below is a simple test case. The "kw" variable has a 'values' key with a string value using single quotes to store the value '" ";':
-------------------------------------------------------------------------------
from Tkinter import *
from ttk import *
root = Tk()
tv = Treeview(root, columns=("foobar",))
tv.heading("foobar", text="Foobar!")
tv.column("#0", width=0)
tv.column("foobar", stretch=True, minwidth=100, width=400)
tv.grid()
kw = {'values': '" ";', 'tags': ''}
tv.insert("", END, iid=None, **kw)
root.mainloop()
-------------------------------------------------------------------------------
This sample triggers this traceback:
Traceback (most recent call last):
File "test.py", line 14, in <module>
tv.insert("", END, iid=None, **kw)
File "C:\Python27\lib\lib-tk\ttk.py", line 1339, in insert
res = self.tk.call(self._w, "insert", parent, index, *opts)
_tkinter.TclError: list element in quotes followed by ";" instead of space
Furthermore, if the 'values' key is changed to the string 'X:"Y ";', you trigger a different traceback:
Traceback (most recent call last):
File "test.py", line 13, in <module>
tv.insert("", END, iid=None, **kw)
File "C:\Python27\lib\lib-tk\ttk.py", line 1339, in insert
res = self.tk.call(self._w, "insert", parent, index, *opts)
_tkinter.TclError: unmatched open quote in list
So definitely a case of something in the parser not handling things properly before sending to the TCL interpreter.
I suspect this is similar to Issue #15861. One can work around this bug by checking for either a whitespace or backslash character in the string, and wrapping the string in curly braces if so, to disable TCL substitution mechanism, and it'll insert the string and display it correctly in the widget.
I have only verified this in Python 2.7.14 at the moment, which is what I primarily work in right now. |
|
Date |
User |
Action |
Args |
2017-12-14 21:35:04 | kumba | set | recipients:
+ kumba |
2017-12-14 21:35:04 | kumba | set | messageid: <1513287304.34.0.213398074469.issue32328@psf.upfronthosting.co.za> |
2017-12-14 21:35:04 | kumba | link | issue32328 messages |
2017-12-14 21:35:04 | kumba | create | |
|