Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttk.Combobox['values'] String Conversion to Tcl #55499

Closed
claytondarwin mannequin opened this issue Feb 22, 2011 · 9 comments
Closed

ttk.Combobox['values'] String Conversion to Tcl #55499

claytondarwin mannequin opened this issue Feb 22, 2011 · 9 comments
Labels
topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@claytondarwin
Copy link
Mannequin

claytondarwin mannequin commented Feb 22, 2011

BPO 11290
Nosy @terryjreedy, @serhiy-storchaka
Superseder
  • bpo-15861: ttk.Treeview "unmatched open brace in list"
  • Files
  • tcl_string_test.py: Illustrates ttk.Combobox['values'] string error.
  • patch11290.diff
  • tested_patch.png: Image of 2 combo boxes. Top with no patch, bottom with patch applied.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-01-15.16:09:07.936>
    created_at = <Date 2011-02-22.17:05:20.595>
    labels = ['type-bug', 'expert-tkinter']
    title = "ttk.Combobox['values'] String Conversion to Tcl"
    updated_at = <Date 2013-01-15.16:09:07.934>
    user = 'https://bugs.python.org/claytondarwin'

    bugs.python.org fields:

    activity = <Date 2013-01-15.16:09:07.934>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-01-15.16:09:07.936>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2011-02-22.17:05:20.595>
    creator = 'claytondarwin'
    dependencies = []
    files = ['20843', '21017', '28284']
    hgrepos = []
    issue_num = 11290
    keywords = ['patch']
    message_count = 9.0
    messages = ['129097', '129417', '129422', '130174', '177349', '177351', '177353', '177355', '180030']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'gpolo', 'claytondarwin', 'serhiy.storchaka', 'PendulumDreams']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '15861'
    type = 'behavior'
    url = 'https://bugs.python.org/issue11290'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @claytondarwin
    Copy link
    Mannequin Author

    claytondarwin mannequin commented Feb 22, 2011

    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

    @claytondarwin claytondarwin mannequin added topic-tkinter type-bug An unexpected behavior, bug, or error labels Feb 22, 2011
    @terryjreedy
    Copy link
    Member

    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.

    @claytondarwin
    Copy link
    Mannequin Author

    claytondarwin mannequin commented Feb 25, 2011

    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

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Mar 6, 2011

    Does the attached patch work for you ?

    @PendulumDreams
    Copy link
    Mannequin

    PendulumDreams mannequin commented Dec 11, 2012

    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.

    @PendulumDreams
    Copy link
    Mannequin

    PendulumDreams mannequin commented Dec 11, 2012

    I should also add that I yellow highlighed where the space is in the image I attached so it easier to see.

    @PendulumDreams
    Copy link
    Mannequin

    PendulumDreams mannequin commented Dec 11, 2012

    On a side note:

    If you pass raw string literals into the combo box as values this issue doesn't happen.

    @serhiy-storchaka
    Copy link
    Member

    bpo-15861 has a more general patch which fixes also this issue.

    @serhiy-storchaka
    Copy link
    Member

    Fixed in bpo-15861. Thank you for report, Clayton Darwin.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants