[Tutor] Tkinter problem

Arden Hall arhall1 at comcast.net
Sun Jun 15 23:07:58 CEST 2008


I'm trying to learn to use Tkinter from "Thinking in Tkinter" and don't 
seem to be able to get the examples to work the way they are supposed 
to.  I have the latest version of Python on a Macbook.  Here's an 
example of the kind of problem I run into:

The source code is:

    from Tkinter import *

    root = Tk()

    myContainer1 = Frame(root)
    myContainer.pack()

    button1 = Button(myContainer1)
    button1["text"} = "Hello, World!"
    button1[background"] = "green"
    button1.pack

    root.mainloop()

I can execute this, but the button isn't green (or any other color I 
try) although it turns blue when I click the mouse on it.  .  Similarly, 
I've tried to  write a  bit of code to create a canvas object and put a 
rectangle in it, but I can't dimension the canvas, change its color,  or 
get the rectangle to appear.  Any advice or suggestion where to look for 
documentation would be greatly appreciated.

Thanks
Arden


More information about the Tutor mailing list