python strings and {} in Tkinter entry widgets

Jeff Hobbs jeff.hobbs at gmail.com
Mon Aug 16 12:40:01 EDT 2010


On Aug 15, 4:41 pm, Chris Hare <ch... at labr.net> wrote:
> I have some code that pulls a value from a database.  In this case, it is three space delimited words.  When I display the value in a Tkinter.Entry widget, the text has curly braces around it, even when there are none in the surrounding the text in the database.
>
> Is this normal, and how do I prevent it or remove them correctly before displaying the text in the Entry widget?

Python ['', '', ''] == Tcl {{} {} {}}
Python 'a word' == Tcl {a word}

You are getting a literal translation occurring, and you need to split/
join or index the items properly.  Without being more clear how you
want to represent your data, what you need isn't clear.  Perhaps you
just need to reference the first index of the variable, or ... who
knows, there are lots of possibilities.

Jeff



More information about the Python-list mailing list