New submission from Joshua Kinard <ku...@gentoo.org>: 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. ---------- components: Tkinter messages: 308340 nosy: kumba priority: normal severity: normal status: open title: ttk.Treeview: _tkinter.TclError: list element in quotes followed by ";" instead of space type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32328> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com