Issue 11290: ttk.Combobox['values'] String Conversion to Tcl (original) (raw)

Created on 2011-02-22 17:05 by claytondarwin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tcl_string_test.py claytondarwin,2011-02-22 17:05 Illustrates ttk.Combobox['values'] string error.
patch11290.diff gpolo,2011-03-06 15:39
tested_patch.png PendulumDreams,2012-12-11 20:31 Image of 2 combo boxes. Top with no patch, bottom with patch applied.
Messages (9)
msg129097 - (view) Author: Clayton Darwin (claytondarwin) Date: 2011-02-22 17:05
In working with the ttk.Combobox (Windows XP, Python 3.1), I have found that setting the values for the popdown using ttk.Combobox['values'] has an problem converting the string to the proper Tcl value when (and this is the only instance I have found) there is a backslash in the string but no spaces. In this case, the string will translate if it is enclosed in curly brackets '{'+mystring+'}', which I believe is the Tcl syntax to not make substitutions. I have attached a short script that illustrates this issue. Clayton
msg129417 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-02-25 20:24
With 3.2, (Winxp) I get combobox with first line, input as r'C:\Python31\Lib\tkinter\test\test_ttk', displayed as "C:Python31Lib kinter est est_ttk" Something either deleted \ or converted \t to tab. Indeed, adding a space to the end of the string or enclosing as you specify inhibits deletion/conversion, so this seems like an error. With imports fixed from Tkinter import * import ttk the file runs fine in 2.7, so this seems 3.x specific problem.
msg129422 - (view) Author: Clayton Darwin (claytondarwin) Date: 2011-02-25 20:39
This is a simple work around. def fix_tcl_error(s): if '\\' in s and not ' ' in s: s = '{'+s+'}' return s You can get the text from the Combobox with no issues. The error is in posting it to the Combobox when you have backslashes and no spaces (I think). I have just been running everything through this def before adding it. It has worked with no problems so far using Windows paths and grep-type search strings. CD
msg130174 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2011-03-06 15:39
Does the attached patch work for you ?
msg177349 - (view) Author: Jayden Kneller (PendulumDreams) Date: 2012-12-11 20:31
I also ran into this issue in python 3.3 64bit on windows 7. I was adding paths into a combo box and was escaping all \'s myself. When I created a folder with a space I noticed the paths with the space had double the \'s I wanted. I removed my escaping and tested the patch and the attached image shows that it works. The top of the image was before, the bottom of the image was after.
msg177351 - (view) Author: Jayden Kneller (PendulumDreams) Date: 2012-12-11 20:33
I should also add that I yellow highlighed where the space is in the image I attached so it easier to see.
msg177353 - (view) Author: Jayden Kneller (PendulumDreams) Date: 2012-12-11 20:36
On a side note: If you pass raw string literals into the combo box as values this issue doesn't happen.
msg177355 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-11 20:49
Issue15861 has a more general patch which fixes also this issue.
msg180030 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-15 16:09
Fixed in . Thank you for report, Clayton Darwin.
History
Date User Action Args
2022-04-11 14:57:13 admin set github: 55499
2013-01-15 16:09:07 serhiy.storchaka set status: open -> closedresolution: fixedmessages: + stage: resolved
2012-12-12 09:46:01 serhiy.storchaka set superseder: ttk.Treeview "unmatched open brace in list"versions: + Python 2.7, Python 3.2, Python 3.4
2012-12-11 20:49:27 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2012-12-11 20:36:24 PendulumDreams set messages: +
2012-12-11 20:33:14 PendulumDreams set messages: +
2012-12-11 20:31:17 PendulumDreams set files: + tested_patch.pngversions: - Python 3.1, Python 3.2nosy: + PendulumDreamsmessages: +
2011-03-06 15:39:22 gpolo set files: + patch11290.diffmessages: + keywords: + patchnosy:terry.reedy, gpolo, claytondarwin
2011-02-25 20:39:52 claytondarwin set nosy:terry.reedy, gpolo, claytondarwinmessages: +
2011-02-25 20:24:55 terry.reedy set nosy: + gpolo, terry.reedymessages: + versions: + Python 3.2, Python 3.3
2011-02-22 17:05:20 claytondarwin create