Is it necessary to call Tk() when writing a GUI app with Tkinter?

Terry Reedy tjreedy at udel.edu
Fri Mar 2 15:19:31 EST 2012


On 3/1/2012 10:43 PM, Terry Reedy wrote:

>> Not sure what is happening on your end, but i don't see any braces.
>
> Are you saying that if you change "Hello_World\n(click_me)" to
> "Hello World\n(click me)", you see
>
> Hello World
> (click me)
>
> as I expected, instead of
>
> {Hellow World
> (click me)}
>
> as I do see? What OS are you running? And what tk version? (I have 8.5.9
> in Win7)

The problem was another subtle bug in the current example":
         self.hi_there["text"] = "Hello",

The spurious comma at the end makes the value of the 'text' attribute a 
one-elememt tuple and not just a string. I presume tcl-based tk handles 
that in the manner appropriate for the tcl equivalent. I believe tcl 
uses spaces rather than commas to separate items, so the braces serve as 
'quotes' to indicate that the contents are one item, not three. Removing 
the comma solves the problem.

-- 
Terry Jan Reedy




More information about the Python-list mailing list